R 是否可以更改ggplot2中图例元素的颜色?
我正试图找到改变与尺寸相关的图例颜色的方法R 是否可以更改ggplot2中图例元素的颜色?,r,ggplot2,legend,R,Ggplot2,Legend,我正试图找到改变与尺寸相关的图例颜色的方法 p <- ggplot(data = mtcars, aes(x = mpg, y = wt))+ geom_point(aes(color = cyl, size = qsec, shape = as.factor(gear))) p p您可以使用guides()将绘图中的size选项调整为所需颜色: #Code ggplot(data = mtcars, aes(x = mpg, y = wt))+ geom_point(aes(c
p <- ggplot(data = mtcars, aes(x = mpg, y = wt))+
geom_point(aes(color = cyl, size = qsec, shape = as.factor(gear)))
p
p您可以使用guides()
将绘图中的size
选项调整为所需颜色:
#Code
ggplot(data = mtcars, aes(x = mpg, y = wt))+
geom_point(aes(color = cyl, size = qsec, shape = as.factor(gear)))+
guides(size = guide_legend(override.aes = list(color = "gray")))
输出: