如何避免绘制以下数据时出现的绘图区域的灰色阴影?
df <-data.frame(x = c(0,0.2,0.5), y = c(0.6,0.7,0.9))
p <-ggplot(df, aes(x, y, ymin=0, ymax=1, xmin=0, xmax=1))
p <- p + geom_point(alpha=2/10, shape=21,
fill="blue", colour="black", size=5)
p
到目前为止很好,但是然后使用 geom_smooth 添加线方程会导致部分背景变成灰色。
p <- p + geom_smooth(method="lm", se=FALSE, formula=y~x, colour="black")
p
关于如何避免这种情况的任何建议?谢谢。
最佳答案
添加 fill=NA
给您的 geom_smooth
称呼:
p + geom_smooth(method="lm", se=FALSE, formula=y~x,colour="black",fill=NA)
关于r - ggplot 中的 geom_smooth 导致部分绘图背景改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11922825/