统计与科研

为什么你画的ggplot2箱线图没横线 哈哈

2020-04-14  本文已影响0人  小洁忘了怎么分身

不知道大家有木有发现,基础包画箱线图是这样的:

boxplot(iris$Sepal.Length~iris$Species)

它是一张有横线的图。
而用ggplot2作图时,莫得感情,莫得横线😕。

library(ggplot2)
ggplot(data = iris,aes(x = Species,y = Sepal.Length))+
  geom_boxplot( width = 0.3)

能不能把横线加上,能啊,搜。

顺便把颜色也加上好了。

ggplot(data = iris,aes(x = Species,y = Sepal.Length,fill = Species))+
  stat_boxplot(geom ='errorbar', width = 0.3)+
  geom_boxplot( width = 0.3)

参考代码:https://stats.stackexchange.com/questions/8137/how-to-add-horizontal-lines-to-ggplot2-boxplot

上一篇 下一篇

猜你喜欢

热点阅读