library(tidyr)
test <- gather(test,parameter,value,O3:PM2.5)
library(ggplot2)
ggplot(test,aes(x=factor(class,levels =c("Annual", "Spring", "Summer", "Autumn", "Winter")),y=value,fill=parameter))+stat_boxplot(geom = "errorbar",width=0.8,lwd=0.1)+geom_boxplot(width=0.8,position=position_dodge(0.8))+**labs(x="Group",y="Concentration(ug/m³)")**+theme_test()
ggplot绘制箱体图如何修改坐标轴标题
最新推荐文章于 2024-08-09 14:28:19 发布
这篇博客展示了如何利用R语言中的tidyr库进行数据整理,然后使用ggplot2库创建箱线图来展示不同季节中O3和PM2.5的浓度分布。通过factor函数设置类别的顺序,并用fill参数区分参数类型,使得数据可视化更加清晰易读。
摘要由CSDN通过智能技术生成