柱状图

如何画出柱状图?

载入R包。


library(ggplot2)

作图数据为R自带数据iris。

画出一个基本的。

ggplot(iris, aes(x = Species, y = Sepal.Length)) + 
  stat_summary(fun.data = "mean_se", geom = "bar")


简单修饰。


ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) + 
  stat_summary(fun.data = "mean_se", geom = "bar", width = 0.3) +
  scale_fill_manual(values = c("steelblue", "orange", "firebrick")) +
  theme_bw()


▌欢迎关注公众号:R语言和统计
▌课程相关咨询可添加R师妹微信: kefu_rstats
▌邮箱:contact@rstats.cn
▌网站:www.rstats.cn
我们致力于让R语言和统计变得简单!




2023-02-22 16:10
首页    ggplot2    柱状图