How do I get the correct shape and color for the points in the legend when adding geom_smooth?
If I add geom_smooth
then I end up with different colored rectangles in the shape legend instead of black circles. How can I prevent this? Here is a sample code example .
library(ggplot2)
df <- data.frame(x=rnorm(100), y=rnorm(100), z=runif(100))
qplot(x, y, size=z, data=df) +
geom_smooth(method='loess', aes(weight=z))
+3
mlt
source
to share
1 answer
This is captured, indicating that the aesthetics are size
specific to the point layer:
ggplot(df, aes(x = x, y = y)) +
geom_point(aes(size = z)) +
geom_smooth(method = "loess", aes(weight = z))
+3
Gregor
source
to share