首页 > 解决方案 > 在ggplot中删除geom_smooth层

问题描述

我通过此代码在单个图中绘制了不同变量的时间图:

landu<-getField(source =landuseh,var = "LU", cover.threshold = 0.01, spatial.extent = mountains, spatial.extent.id = "SEA" )
year<-selectYears(x = landu, first = 1750, last = 2100)
datalu<-as.data.frame(yearssel1)

aggregate1<-aggregateSpatial(yearssel1)
print(aggregate1)
p<-plotTemporal(aggregate1,layers=c("CL","PA", "NA"))

上面的代码是通过 R 中的 DGVMTools 包完成的。

plot2<-p+theme_classic()+labs(y= "Fraction", x = "Year")+
  ggtitle("",subtitle ="")+guides(color=guide_legend(override.aes=list(fill=NA)))+
  theme(legend.title = element_blank())+
  theme(legend.position = "bottom", text = element_text(size = theme_get()$text$size * 1.2))+
  theme(panel.background = element_rect(colour = "black", size=1))

ggplot

geom_smooth 是自动绘制的(我从来没有通过命令来绘制它)。我的 ggplot 层是:

plot2$layers
[[1]]
geom_smooth: se = TRUE, na.rm = FALSE, orientation = NA, flipped_aes = FALSE
stat_smooth: method = lm, formula = y ~ x, se = TRUE, n = 80, fullrange = FALSE, level = 0.95, na.rm = FALSE, orientation = NA, method.args = list(), span = 0.75
position_identity 

[[2]]
geom_line: na.rm = FALSE, orientation = NA, flipped_aes = FALSE
stat_identity: na.rm = FALSE
position_identity 

如何删除几何平滑线?并且只保留几何平滑阴影后面的那些线条?

标签: rggplot2

解决方案


推荐阅读