r - stat_smooth() 的其他范围

标签 r ggplot2 range data-fitting

ggplot2 -功能stat_smooth()有选项 fullrange=TRUEFALSE这决定了拟合是在数据范围还是图表范围内绘制。

有没有办法给stat_smooth()一个杂项?例如。如果我的图在 (0,100) 中有 x 但在 (40,60) 中有拟合数据 x,则绘制 (30,70) 中范围 x 的平滑拟合。

最佳答案

使用 xseq在您的 stat_smooth调用如下:

stat_smooth(xseq = seq(30,70, length=80))

//@哈德利:为什么是xseq , 和 n作为绘图参数未记录在 ?geom_smooth 中?源代码见这里:https://github.com/hadley/ggplot2/blob/master/R/stat-smooth.r

示例: (改编自 ?geom_smooth)
ggplot(mtcars, aes(qsec, wt)) + 
  geom_point() + 
  xlim(c(10,30)) + 
  stat_smooth(method=lm, fullrange = TRUE, xseq = seq(11,25, length=80))

结果:

enter image description here

关于r - stat_smooth() 的其他范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30345101/

相关文章:

jquery - 范围输入元素 : Is there a way to Dynamically Change the Min Value?

python - 名称错误 : global name 'xrange' is not defined in Python 3

c++ - Armadillo C++ : Sorting a vector in terms of two other vectors

r - 将 for 循环的结果存储在对象或矩阵中

r - 将一些分组列添加到 R 中的嵌套数据框

r - ggplot 未显示所有 x 轴刻度

r - 使用 ggplot 绘制直方图中条形观察值的数量

R:来自矩阵的多个晶格水平图

r - ggplot2 绘制两个图例

MySQL:任何改进最佳匹配存储过程的建议