Different range of stat_smooth ()

ggplot2-function stat_smooth()has an option fullrange=TRUEor FALSE, which decides whether the fit will be drawn on the data range or the range of the graph.

Is there a way to provide a stat_smooth()different range? For instance. if my graph has x at (0,100) but the set data is x at (40,60) to build a smoothed match for the range x at (30,70).

+4
source share
1 answer

Use xseqin a call stat_smoothas follows:

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

@Hadley: Why xseqand nhow are capitalization options not listed in ?geom_smooth? See here the source code: 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

+3

Source: https://habr.com/ru/post/1588953/


All Articles