-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add color_range argument to scatter #72
Comments
I don't believe that's the case, and if it were it would be a bug... Can you provide an example? The code that internally does this computation is: https://github.com/plotly/plotly_express/blob/master/plotly_express/_core.py#L657-L665 I should note that this will change once plotly.js 1.48 comes out, which supports native cross-trace colorscale sharing. Either way, if you have an example where |
import plotly_express as px
import pandas as pd
data = {
"x": {
0: 36,
1: 8,
2: 35,
3: 2,
4: 25,
7: 29,
8: 9,
9: 13,
10: 15,
12: 19,
13: 21,
14: 6,
15: 4,
16: 33,
17: 1,
18: 5,
19: 17,
20: 11,
21: 23,
22: 27,
23: 31,
},
"row": {
0: 6.0,
1: 6.0,
2: 6.0,
3: 6.0,
4: 6.0,
7: 6.0,
8: 6.0,
9: 6.0,
10: 6.0,
12: 6.0,
13: 6.0,
14: 6.0,
15: 6.0,
16: 6.0,
17: 6.0,
18: 6.0,
19: 6.0,
20: 6.0,
21: 6.0,
22: 6.0,
23: 6.0,
},
"col": {
0: -5.0,
1: 1.0,
2: -2.0,
3: 5.0,
4: 3.0,
7: -1.0,
8: 4.0,
9: 4.0,
10: 0.0,
12: 0.0,
13: 3.0,
14: 1.0,
15: 5.0,
16: -3.0,
17: 5.0,
18: 1.0,
19: 0.0,
20: 4.0,
21: 3.0,
22: -1.0,
23: -3.0,
},
"color_y": {
0: 0.0,
1: 0.0,
2: 0.0,
3: 0.0,
4: 0.0,
7: 0.0,
8: 0.04500381388253241,
9: 0.0,
10: 0.0625,
12: 0.0,
13: 0.0,
14: 0.06666666666666667,
15: 0.0,
16: 0.0,
17: 0.007744954707029009,
18: 0.008126576654053435,
19: 0.788848364894659,
20: 0.9773527528809217,
21: 0.907694404153694,
22: 0.013756613756613755,
23: 0.00870253164556962,
},
}
df = pd.DataFrame(data)
px.scatter(
df,
x="x",
y="color_y",
color="color_y",
facet_col="col",
facet_row="row",
color_continuous_scale=px.colors.sequential.Sunset,
) The y value in each subplot should be the same as the color. But clearly, there are purple values which have very low y values and thus shouldn't be purple. Also, in the third column, there is a red dot that has a color value of zero. |
Thanks! That certainly seems like a bug, I'll get cracking on fixing it :) |
Great! Any chance you would add args for setting the |
what would be the use-case, once this bug is fixed? |
I think there are lots of use cases. Matplotlib scatter supports it with Seaborn also supports it. The main use case is to have the same color scale across multiple plots. For instance, if I have a px.Scatter of data today and then I make a new plot of updated data tomorrow, I want the color scale for those two plots to be the same. If my max color column value today is |
Thanks for the crisp justification, I'm convinced :) A couple of considerations:
|
e.g.: This is how BTW, you've done a fantastic job with plotly express... It is the plotting package I have always wanted. :-) |
the And thanks for the kind words! It's also the plotting package I have always wanted (modulo the occasional 🙈 bug like this one!) and it's nice to know I'm not the only one :) |
I just pushed v0.1.9 to PyPI with the fix... pushing to conda-forge in a bit :) |
and up on conda now... will leave this issue as the |
Wow, impressively fast. Thanks! |
(embarrassment is a strong motivator to fix things fast :P) |
🎉 |
(will be in the next release... hopefully today!) |
Being able to set the color range for continuous color columns would be very useful. e.g.:
Currently the behavior seems to use different color scales across row and column facets, which means that the single color-scale legend is inaccurate.
The text was updated successfully, but these errors were encountered: