-
Notifications
You must be signed in to change notification settings - Fork 2k
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
the default value of ScaleBinned$n.breaks should be 4, not 5. #3580
Conversation
The default value of ScaleBinned$n.breaks was set to the same as trans objects. The default value of trans objects can map data to 5 colours in plot and legend, which is a direct-viewing color display. However, when n.breaks is set to 5, ScaleBinned will map the data to 6 colours! This occur in the codes: https://github.com/tidyverse/ggplot2/blob/115c3960d0fd068f1ca4cfe4650c0e0474aabba5/R/scale-.r#L914 and https://github.com/tidyverse/ggplot2/blob/115c3960d0fd068f1ca4cfe4650c0e0474aabba5/R/scale-.r#L928 So I think the default value of ScaleBinned$n.breaks should be 4, not 5, then it can works the same way as trans objects.
Could you provide a reprex that demonstrates the problem with the current code base? |
@clauswilke I have not used reprex before. |
@clauswilke |
Ah @microly, the GFW issue with reprex/imgur is unfortunate, and known. There is an open issue in reprex in hopes of resolving this one day: tidyverse/reprex#214 |
Here are the examples: By now, The default value of ScaleBinned$n.breaks is 5. Scale_fill_fermenter (which based on ScaleBinned) has six colours in the legend, which is different from scale_fill_distiller (which based on ScaleContinuous). After setting ScaleBinned$n.breaks to 4, it works the same way like scale_fill_distiller, both of which have 4 colours in their legends.
|
@batpigandme |
We are pending an update to the scales package before we can actually pass |
OK, thanks for your reply~ |
I am closing this. The default of 5 makes sense as you'd generally want a break in the middle of your range instead of having a bin that spans over the middle. You shouldn't use the legend guide with a binned scale as it does not communicate the actually scale. Use the 'bins' guide instead |
The default value of ScaleBinned$n.breaks was set to the same as trans objects.
The default value of trans objects can map data to 5 colours in plot and legend, which is a direct-viewing color display.
However, when n.breaks is set to 5, ScaleBinned will map the data to 6 colours!
6 colours display is not so good as 5 colours.
This occur in the codes:
ggplot2/R/scale-.r
Line 914 in 115c396
and
ggplot2/R/scale-.r
Line 928 in 115c396
So I think the default value of ScaleBinned$n.breaks should be 4, not 5, then it can works the same way as trans objects.
@thomasp85 , please consider it, thanks!