r - 我的 ggplot 折线图上的日期没有排序
问题描述
我有从 3 月 10 日到 5 月 14 日的数据,但 x 轴没有按给定的顺序绘制。
rm(list = ls())
ahm <- read.csv("PM2.5.csv")
View(ahm)
ggplot(ahm, aes(x=date, group = 1)) +
geom_line(aes(y = X2019), color = "darkred", size = 1) +
geom_smooth(data=ahm, formula= y ~ x,method= "loess", aes(x = date, y = X2019,group=1)) +
geom_line(aes(y = X2020), color = "steelblue", size = 1) +
geom_smooth(data=ahm, formula= y ~ x,method= "loess", aes(x = date, y = X2020,group=1)) +
geom_line(aes(y = X2021), color = "green", size = 1) +
geom_smooth(data=ahm, formula= y ~ x,method= "loess", aes(x = date, y = X2021,group=1)) +
labs(x= "Date", y="Concentration", title= "Ahmedabad PM2.5") +
theme(axis.text.x = element_text(angle = 90))
解决方案
推荐阅读
- testcafe - 通过部分相等的 id/class 值定位多个元素
- c# - C# LINQ,其中 list1 包含没有重复的 list2
- asp.net-mvc - 为什么使用 glyphicon-chevron-down 的 bootstrap 3 可折叠面板会在某些苹果设备上显示苹果枪表情符号?
- python - 在python中编辑已经打印的文本
- sql - 如何在 SQL 中将四列值附加到两列中
- typescript - TypeScript 中的 D3 库(Cognos Analytics)
- arrays - 从 scikit.rf 网络中减去常量
- javascript - 在 WebView 中添加限制以阻止在 WebView 中打开其他链接
- qt - 仅在 QML 中创建 TreeView
- c# - 索引视图未将参数 Id 传递给 mvc 控制器