r - 绘图中的重叠线(ggplot2)
问题描述
我需要一些帮助来创建类似图 2 的图。我不知道问题是我的数据还是代码。但正如您在第一个图形中看到的那样,存在重叠,我想要一个更柔和的图形作为第二个图像。另一方面。有人可以订购日期吗?
ggplot(data = consum, mapping = aes(x = Month, y = Cpc, color = Year, group = 1)) +
geom_line() +
facet_wrap(~Type) +
theme_bw() +
scale_color_manual(values = c("orange", "blue"))
```
structure(list(Month = c("January", "Frebrary", "March", "April",
"January", "Frebrary", "March", "April", "January", "Frebrary",
"March", "April", "January", "Frebrary", "March", "April", "May",
"January", "Frebrary", "March", "April", "January", "Frebrary",
"March", "April"), Cpc = c(52.6030417616108, 52.3807979985595,
63.4812345277527, 69.9337994172852, 4.87131485047933, 5.10130976154746,
5.81295804297682, 6.85707419263629, 7.155082484813, 7.24882986945935,
8.32846647323954, 9.80847493902699, 6.94921351149698, 6.55179853175549,
7.35259139659446, 6.95037273611445, 8.03280438298055, 4.60674099035869,
4.47914291992134, 4.95627076108138, 4.57283076670216, 51.3581426441543,
47.660340330082, 52.8289135861524, 50.6656566779732), Year = c("2020",
"2020", "2020", "2020", "2020", "2020", "2020", "2020", "2020",
"2020", "2020", "2020", "2019", "2019", "2019", "2019", "2019",
"2019", "2019", "2019", "2019", "2019", "2019", "2019", "2019"
), Type = c("Total feeding", "Total feeding", "Total feeding",
"Total feeding", "Fresh vegetables", "Fresh vegetables", "Fresh vegetables",
"Fresh vegetables", "Fresh fruits", "Fresh fruits", "Fresh fruits",
"Fresh fruits", "Fresh fruits", "Fresh fruits", "Fresh fruits",
"Fresh fruits", "Fresh fruits", "Fresh vegetables", "Fresh vegetables",
"Fresh vegetables", "Fresh vegetables", "Total feeding", "Total feeding",
"Total feeding", "Total feeding")), row.names = c(NA, -25L), class = c("tbl_df",
"tbl", "data.frame"))
解决方案
推荐阅读
- python - 如何使用带有烧瓶的 apscheduler 运行 Python 脚本以每天运行?
- css - 如何保持宽度小但 img 适合 div 容器
- sql - 将 varchar 值转换为数据类型 numeric 时 SQL 转换失败
- python - 从文本文件中读取特定的行或字符,但无法识别文本
- javascript - geolocated 给出了错误的位置
- sql - Oracle DB sql 将 table_names 模式分组到一个组中
- gremlin - 如何查看 gremlin 的任何属性中是否存在值?
- r - 无法从 ARIMA 模型中识别 RMSE
- python - 如何在 Python 中使用 uproot 读取 TMatrixT?
- python - python if else 语句只返回第一个条件