You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changing the order of the breaks (colors stay the same):
p = ggplot(tmp, aes(x='x', y='y', color='col')) + geom_point()
p = p + scale_color_discrete(name='col', breaks=[True, False])
p
In adding custom labels, the order follows the breaks:
p = ggplot(tmp, aes(x='x', y='y', color='col')) + geom_point()
p = p + scale_color_discrete(name='col', breaks=[True, False], labels=['true is blue', 'false is red'])
p
If you want to specify custom colors, however, values appears to follow original (presumably 'factor()` order):
p = ggplot(tmp, aes(x='x', y='y', color='col')) + geom_point()
p = p + scale_color_manual(name='col', breaks=[True, False], labels=['true is blue', 'false is red'], values=['red', 'black'])
p
Using limits instead of breaks fixes this:
p = ggplot(tmp, aes(x='x', y='y', color='col')) + geom_point()
p = p + scale_color_manual(name='col',
limits=[True, False],
labels=['true is blue', 'false is red'],
values=['blue', 'red'])
p
I tend to use limits to, say, exclude something from a range, using breaks/labels to change labels, with the assumption that values should correspond to break order, as is specified by ggplot2 docs:
The values will be matched in order (usually alphabetical) with the limits of the scale, or with breaks if provided.
If this is the intended behavior, maybe a note in the docs would help understand what's ordered by breaks vs. what's ordered by the underlying, say, pd.Categorical order. Many thanks for taking a look.
The text was updated successfully, but these errors were encountered:
Btw, I just made a submission to r/dataisbeautiful on an analysis of 3.1 million reddit comments. plotnine generated the scatter plots used, which I think it turned out really nice :) Thanks for continuing to provide and maintain the best plotting library in python. I tell everyone at work about it any chance I get.
Btw, I just made a submission to r/dataisbeautiful on an analysis of 3.1 million reddit comments. plotnine generated the scatter plots used, which I think it turned out really nice :)
Nice plots there. It would be interesting to see how the vary over time!
I noticed unexpected behavior and wanted to bring it here for comment/input.
Toy example, default behavior:
Changing the order of the breaks (colors stay the same):
In adding custom labels, the order follows the breaks:
If you want to specify custom colors, however,
values
appears to follow original (presumably 'factor()` order):Using
limits
instead ofbreaks
fixes this:This is not the
ggplot2
behavior, however.I tend to use
limits
to, say, exclude something from a range, usingbreaks/labels
to change labels, with the assumption thatvalues
should correspond to break order, as is specified by ggplot2 docs:If this is the intended behavior, maybe a note in the docs would help understand what's ordered by
breaks
vs. what's ordered by the underlying, say,pd.Categorical
order. Many thanks for taking a look.The text was updated successfully, but these errors were encountered: