添加 geom_smooth 时如何为图例中的点获得正确的形状和颜色?
How to get proper shape and color for points in legend when adding geom_smooth?
如果我添加 geom_smooth
,那么我会在 shape 图例中得到不同颜色的矩形,而不是黑色圆圈。我怎样才能防止这种情况发生?这是 sample code.
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))
这是通过指定 size
美学特定于点图层来解决的:
ggplot(df, aes(x = x, y = y)) +
geom_point(aes(size = z)) +
geom_smooth(method = "loess", aes(weight = z))
如果我添加 geom_smooth
,那么我会在 shape 图例中得到不同颜色的矩形,而不是黑色圆圈。我怎样才能防止这种情况发生?这是 sample code.
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))
这是通过指定 size
美学特定于点图层来解决的:
ggplot(df, aes(x = x, y = y)) +
geom_point(aes(size = z)) +
geom_smooth(method = "loess", aes(weight = z))