-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
featurea feature request or enhancementa feature request or enhancementguides 📏visual change 👩🎨Rendering change that will affect look of outputRendering change that will affect look of output
Description
Currently, if two layers have non-overlapping values in an aesthetic and different key glyphs, both glyphs are drawn for all data values, as seen here:
library(ggplot2)
ggplot(mtcars, aes(disp, mpg)) +
geom_point(aes(color = "points")) +
geom_smooth(aes(color = "regression line"))
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'
This is suboptimal, because the line glyph is not sensible for the "points" entry and the point glyph is not sensible for the "regression line" entry. The workaround currently is to use override.aes()
, but it is cumbersome and requires deep knowledge about the default settings for various key glyphs:
ggplot(mtcars, aes(disp, mpg)) +
geom_point(aes(color = "points")) +
geom_smooth(aes(color = "regression line")) +
guides(
color = guide_legend(
override.aes = list(
shape = c(19, NA),
linetype = c(NA, 1),
fill = c(NA, "grey60")
)
)
)
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'
There should be an option, and maybe made the default, to produce the second outcome whenever appropriate.
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancementguides 📏visual change 👩🎨Rendering change that will affect look of outputRendering change that will affect look of output