首页 文章

ggplot2:使用stat_summary参数时填写问题点

提问于
浏览
0

我有以下代码:

ggplot(iris, aes(x=Species, y=Sepal.Length)) + 
stat_summary(fun.y=mean, geom='point', size=2, fill='white')

我知道有可能使用 iris 数据绘制这个均值的其他方法 . 但是,对于我自己的数据,这是唯一的方法 .

问题:上面的代码不会给出白色填充点,而是纯黑色点 . 使用 stat_summary 参数时是否有设置填充颜色的方法?

谢谢!

1 回答

  • 3

    要么使用 color 而不是 fill

    ggplot(iris, aes(x=Species, y=Sepal.Length)) + 
    stat_summary(fun.y=mean, geom='point', size=2, color='white')
    

    或使用具有填充和边框颜色的符号形状

    ggplot(iris, aes(x=Species, y=Sepal.Length)) + 
    stat_summary(fun.y=mean, geom='point', size=2, shape=21, fill="blue", color="red")
    

相关问题