Skip to content

Added feature to separately color the middle line of crossbar and box… #3505

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

Closed
wants to merge 1 commit into from

Conversation

capebulbs
Copy link

…plot

To realize the minimalist style of boxplot like the one inside
http://biochemres.com/beautiful-minimalist-boxplots-with-r-and-ggplot2
Instead of adding extra geom_segment over geom_boxplot, now the color of middle bar can be colored separately by setting middle.colo(u)r. And this feature can be turned off by setting separate.middle = FALSE, the middle bar will be colored with the outline of boxplot/crossbar by the col parameter, which acts as what ggplot2 does currently

…plot

To realize the minimalist style of boxplot like the one inside
http://biochemres.com/beautiful-minimalist-boxplots-with-r-and-ggplot2
Instead of adding extra geom_segment over geom_boxplot, now the color of middle bar can be colored separately by setting middle.colo(u)r. And this feature can be turned off by setting separate.middle = FALSE, the middle bar will be colored with the outline of boxplot/crossbar by the col parameter, which acts as what ggplot2 does currently
@capebulbs
Copy link
Author

capebulbs commented Aug 27, 2019

sample code:
# also supported in legends
ggplot(mpg, aes(displ, hwy, col = drv, fill = drv)) + geom_boxplot(middle.color = "white")
Uploading plot_zoom_png.png…

# turn off this feature by setting separate.middle = FALSE
ggplot(mpg, aes(displ, hwy, col = drv)) + geom_boxplot(middle.color = "white", separate.middle = FALSE)

Uploading plot_zoom_png copy.png…

@clauswilke
Copy link
Member

Please take a look at this comment and the surrounding conversation:
#3485 (comment)

@capebulbs
Copy link
Author

capebulbs commented Aug 28, 2019

Please take a look at this comment and the surrounding conversation:
#3485 (comment)

I've read the #3485, and I think my pull request is not like it, I just want to make the plot look better, because in the past for making the boxplot/crossbar have the same fill and color which, in my point of view, looks more beautiful, the middle bar will also be the same color and cannot be seen anymore, I have to add an extra geom_segment to plot another middle bar, which is not an elegant approach, in my PR #3505, this feature has already been integrated into ggplot2 itself, and the three newly-added arguments are not mapped in aes, so it does note affect the mapping of data, just for a better look.

@yutannihilation
Copy link
Member

I think a geom can have colour-related parameters outside of the hierarchy of aesthetics, as GeomBoxplot already has outlier.colour. But... I rather feel your middle.colour is not the case; it should be in the hierarchy, if it is to be implemented.

@clauswilke
Copy link
Member

In my opinion, moving color parameters outside of the hierarchy of aesthetics is almost never warranted. outlier.colour was added a long time ago, before we fully understood how to implement hierarchical aesthetics. Now that we know how it works and that it works fine, it's unclear that keeping it as a parameter only is the right choice.

@yutannihilation
Copy link
Member

Ah, agreed. So, do you mean this PR should consider moving outlier.colour into the hierarchy first, and then implement middle.colour in the hierarchy?

@clauswilke
Copy link
Member

That should at least be under consideration, yes.

@capebulbs
Copy link
Author

OK, I'll try to put it into the hierarchy of aesthetics, thank you for your suggestions!

@clauswilke
Copy link
Member

Closing this PR.

@capebulbs: If you still plan to implement this feature along the lines outlined in my comments, please open a new PR.

@clauswilke clauswilke closed this May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants