嗨,我正在尝试通过在 ggplot 中使用 hexplots 来查看可视化数据集的不同方法。
我基本上想要一个带有
1.黄土线
2. 回归线
3.x=y 线 --> 相当于 abline(0,1)
到目前为止,我已经想出了这样的代码:
c <- ggplot(mtcars, aes(qsec, wt))
c+stat_binhex()+stat_smooth(method="loess", colour="red")+stat_smooth(method='lm', se=FALSE, colour="orange")+ geom_abline(intercept=0, slope=1)
这给出了下面的图片,但我仍然没有看到 x=y 引用线。请帮忙。我不确定为什么它不起作用。谢谢
最佳答案
y=x 引用线不在您绘制的坐标范围内。如果你改为
geom_abline(slope=1, intercept=-15)
你会在情节上看到你的线。
关于r - 将 x=y 线添加到 ggplot2 中的 hexplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20436549/