-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different colors or colormaps for different data series #215
Comments
Thank you for submitting your first issue with us! 🎉 Our response time may vary, but we will get back to you as soon as possible. To help us help you, please make sure you have provided all the necessary information in your issue's description. 🙏 If you'd like to contribute to the project (maybe even fix the issue yourself!), please check out our contributing guidelines. Welcome aboard! 🚀 |
Ciao @lorenzoamir! Thanks for submitting this feature request and providing a clear example plot right away! I love the idea and I've thought about implementing this in the past but never had the time. I'll try to have a look at it and make a quick assessment of the effort required. For these sort of changes, I always have to consider backwards compatibility, updates to the current documentation, user experience, how the API should look like and its impacts on the long-term maintainability of the project, etc... If you already have a good idea of how you think the API could look like from the user's perspective let me know. |
From the top of my head, we could either somehow tap into the existing I think I prefer the first option as adding yet anther "color" parameter would make things more confusing for end users, given that we already have |
I agree. Maybe something like passing a list of colors to the |
I think that the change that requires the least amount of changes is to introduce a new colormode (e.g. trace-index-row-wise) that will take the index of each row's trace (0 and 1 in your example) and use that to grab colors form a colorscale. In your example, the colorscale would have these two entries only: (
(0.0, "red"),
(1.0, "blue"),
) I'll try to work on a draft pull request today. |
@lorenzoamir what do you think of this interface for now? |
PR (WIP): #224 |
Ideally, ridgeplot should probably use the same conventions used by Plotly express for both continuous and discrete coloring options. Here are the official references:
I'll create a new issue for this. |
@lorenzoamir I've merged #224 so I'll close this issue. Let me know if this solution worked for you :) For others coming here, I'm moving the more general discussion around more color options to #226. |
FYI: In the latest version of ridgeplot you can use the following simplified notation: import numpy as np
from ridgeplot import ridgeplot
# Generate some sample data
my_samples = [
[
np.random.normal(n, size=600),
np.random.normal((n + 1), size=600),
]
for n in range(4, 0, -2)
]
# Create a ridgeplot and color the traces per row as red and blue
fig = ridgeplot(
samples=my_samples,
colorscale=["red", "blue"],
colormode="trace-index-row-wise",
coloralpha=0.9,
linewidth=0,
)
fig.update_layout(height=450, width=800)
fig.show() Again, for the ones interested, the progress in adding more coloring modes can be found in #226 |
Hi, thank you for this package.
I was wandering if it was possible to have the colors (or colormaps) represent categorical data. For example, in the minimum and maximum temperature example in the documentation, have all data regarding minimum temperature in blue and data regarding maximum temperatures in red.
I made an example image of what I would like to achieve:
Thank you
The text was updated successfully, but these errors were encountered: