我的 Dataframe 如下所示:
dput(B8A)
structure(list(ID = c("AUR", "AUR", "AUR", "AUR", "AUR", "AUR",
"LAM", "LAM", "LAM", "LAM", "LAM", "LAM", "P0", "P01", "P02",
"P1", "P18", "P2", "P22", "P23", "P24", "P3", "P4"), nD_SOS = c(129L,
349L, 256L, 319L, 306L, 128L, 309L, 244L, 134L, 356L, 131L, 302L,
276L, 296L, 294L, 310L, 337L, 291L, 308L, 295L, 308L, 303L, 310L
), nNDVI_SOS = c(119L, 374L, 272L, 329L, 328L, 152L, 317L, 246L,
129L, 378L, 152L, 315L, 358L, 314L, 310L, 305L, 363L, 305L, 281L,
274L, 285L, 302L, 311L), crop = c("sunfl", "wwht", "wrap", "wwht",
"fbn", "sunfl", "wwht", "wmust_vetch", "irr_corn", "wwht", "irr_corn",
"wwht", "wrap", "wrap", "wrap", "wrap", "wwht", "wrap", "wrap",
"wrap", "wrap", "wrap", "wrap"), year = c(2016, 2016, 2017, 2018,
2019, 2020, 2015, 2016, 2017, 2017, 2019, 2019, 2016, 2016, 2016,
2017, 2018, 2017, 2015, 2015, 2015, 2017, 2018)), row.names = c(NA,
-23L), class = "data.frame")
我想基于不同的列条件在nD_SOS和nNDVI_SOS之间做一个散点图。条件是只获取年2017 和作物* Package * 的散点图。
我一直在用这个代码绘图:
p3 <- ggplot(nB8A_SOS_KRR25_crop, aes(x=nNDVI_SOS, y=nD_SOS)) +
geom_point() +
stat_regline_equation(label.x=30, label.y=310) +
stat_cor(aes(label=..rr.label..), label.x=30, label.y=290)+
geom_smooth(method=lm , color="red", fill="#69b3a2", se=TRUE) +
ggtitle("B8A KRR 25") +
theme_ipsum()
p3
我们的想法是添加一段代码来显示特定年份和作物的数据。
任何帮助都将不胜感激。
1条答案
按热度按时间u5rb5r591#