我试图在带有分箱数据的情节中添加带有geom_smooth的回归线。该线条出现但隐藏在图表的分区区域后面。我试图弄清楚如何让geom_smooth对象出现在它前面。
Nbin <- 150
bindata <- with(DEMtestf50, condense(bin(Delta_z, find_width(Delta_z, Nbin)),bin(veg_height, find_width(veg_height, Nbin))))
smoothBinData <- smooth(peel(bindata), h=c(15, 15))
plot.new()
ggplot(data= bindata, aes(veg_height, Delta_z, fill = .count))+
geom_smooth(data= bindata, aes(veg_height, Delta_z, col="Tree height vs DEM error"), method = "lm")+
geom_tile() + ggtitle("Tree Height vs DEM Error") +
ylab("Tree Height (m)") + xlab("Delta Height (m)")