Repository navigation
Set outline type for geom_density as geom_area - #3708
Conversation
yutannihilation
left a comment
There was a problem hiding this comment.
Looks good, but..., I'm wondering if we can safely make this change.
Different from the case of GeomRibbon, I guess there are already many usages of full-stroking outlines on GeomDensity. That's why I didn't include GeomDensity in #3529.
Probably I'm just too timid because changing the outline of GeomDensity is one of my trauma around ggplot2. Let me think a bit more after drinking some coffee...
| show.legend = NA, | ||
| inherit.aes = TRUE) { | ||
| inherit.aes = TRUE, | ||
| outline.type = 'upper') { |
There was a problem hiding this comment.
| outline.type = 'upper') { | |
| outline.type = "upper") { |
|
You need to add |
|
You are already breaking peoples code as geom_density now uses @hadley do you have any objections to this visual change? |
|
Hmm, you are right. Hope this is OK this time... |
|
@thomasp85 @hadley I want to propose renaming option |
|
I am honestly against. The full stroking of density plots has always looked ugly to my eye. I’m for the renaming, though The sides and lower bound in a density plot is not really data, and stroking them just creates visual noise IMO |
Thanks, agreed. After some investigation, I now agree that drawing the upper lines only is the right thing as base R does so. plot(density(diamonds$carat, adjust = 5))What makes me uneasy with upper-only p <- ggplot(diamonds, aes(carat)) +
geom_density(adjust = 5)
patchwork::wrap_plots(
p + ggtitle("(default)"),
p + ggtitle("(expanded)") + expand_limits(x = -0.5)
)
Sure. |
|
I agree that the rightmost is more pleasing, but I think that ggplot2 has historically erred to the side of keeping the data-range. This is also done by default in violin plots. Extrapolating is something you have to do wilfully, as it creates data from thin air |
|
Sounds fair, but let me dig into the history... |



The new stroking of
geom_ribbon()andgeom_area()didn't make it togeom_density()This PR adds it and make it behave likegeom_area()