从 ggplot2 中的 geom_smooth 中删除线

标签 r ggplot2

我试图从 geom_smooth 中删除回归线,只保留置信区间。我试过 size = 0 , size = NULL , 和 size = NA ,但没有工作。是否有任何人都知道的简单解决方法?

baseball <- ddply(x, .(id), transform, bat.avg = h/ab)
hank <- subset(baseball, id == 'aaronha01')
ggplot(hank, aes(x = year, y = bat.avg)) +
  geom_line(size = 1.2, color = '#336699') +
  geom_smooth(fill = '#bf3030', size = NA) +
  labs(x = '', y = '')

Hank Aaron's Batting Average

最佳答案

您可以设置 linetype=0geom_smooth()删除线。

ggplot(mtcars,aes(wt,mpg))+geom_smooth(linetype=0)

enter image description here

关于从 ggplot2 中的 geom_smooth 中删除线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16134425/

相关文章:

R:如何将包提供的方法导出到 PSOCK 集群?

r - 提取多个时间序列的子集

r - 如何将时间列拆分为间隔(例如 30 分钟或 1 小时)并根据日期或月份绘制它

用于 R 注释的正则表达式 Emacs

r - R 中的 Yearweek 解析错误

r - 将数组写入 CSV,col.names = F 的意外行为

r - 设置ggplot2标签背景色

r - 没有ggplot2图正在工作: "Error in y[setdiff(names(y), names(x))] : object of type ' closure' is not subsettable"

r - 彩色 geom_bar() 绘图

r - ggplot2:绘制几何图形中因子的顺序