首页 > 解决方案 > 隐藏在图的分箱区域后面的几何回归线

问题描述

我正在尝试在带有分箱数据的图中添加带有 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)") 

在此处输入图像描述

标签: rggplot2

解决方案


推荐阅读