ggplot2为stat_summary传说 [英] ggplot2 legend for stat_summary
本文介绍了ggplot2为stat_summary传说的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ggplot(results,aes(x =因子,y = proportionPositive))+
geom_boxplot()+
stat_summary(fun.data =mean_cl_normal,color =red,shape = 4)
解决方案
这是做到这一点的一种方法:
- 将美学映射到形状,即aes(shape =mean)
- 创建手动形状比例,即scale_shape_manual()
#创建虚拟数据
结果< - data.frame(
因子=因子(rep(1:10,100)),
proportionPositive = rnorm(1000))
#绘制结果
ggplot(结果,aes(x = factor, y = proportionPositive))+
geom_boxplot()+
stat_summary(fun.data =mean_cl_normal,
aes(shape =mean),
color =red,
geom =point)+
scale_shape_manual(,values = c(mean=x))
How can I create a legend informing that the red cross is the mean?
ggplot(results, aes(x=factor, y=proportionPositive)) +
geom_boxplot() +
stat_summary(fun.data = "mean_cl_normal", colour = "red", shape=4)
解决方案
Here is one way of doing it:
- Map an aesthetic to a shape, i.e. aes(shape="mean")
- Create a manual shape scale, i.e. scale_shape_manual()
# Create dummy data results <- data.frame( factor=factor(rep(1:10, 100)), proportionPositive=rnorm(1000)) # Plot results ggplot(results, aes(x=factor, y=proportionPositive)) + geom_boxplot() + stat_summary(fun.data = "mean_cl_normal", aes(shape="mean"), colour = "red", geom="point") + scale_shape_manual("", values=c("mean"="x"))
这篇关于ggplot2为stat_summary传说的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文