Closed
Description
I've run into some unexpected behavior when using geom_density_2d
.
If I run
library(ggplot2)
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
geom_smooth(aes(color = drv))
The legend title corresponds to the variable name (drv).
But if I add a geom_density_2d
layer that I want plotted under the smooths, the legend title changes to "colour".
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
geom_density2d() +
geom_smooth(aes(color = drv))
I'm aware that I could change this manually with guides(color = guide_legend(title = "drv"))
and so it's not that big of a deal, but it did seem odd to me.