Better documentation of `xseq` for `stat_smooth()`
The xseq argument is a sort of hidden option for stat_smooth() allowing to select where to draw the smooth line.
Would it be relevant to mention it in the documentation and eventually to provide an example?
I'm not sure if it is hidden on purpose or not, but typically such options aren't advertised to users because they're considered internal.
Given it's presence in compute_group it is exposed to users, whether we document it or not... My guess is that it has been omitted by an error. I doubt @Hadley can remember either way...
We should in general document all arguments available to users so the best way forward is to lift the argument up into the constructor and document it
It's pretty esoteric, so I think we should only bother to document it if it's really required.
It is more flexible that fullrange and quite useful to extend a line only to the left to show the intercept.
Currently fullrange = TRUE extend to both side. There is no option fullrange = "right" or fullrange = "left" but it could easily be done through xseq.
See an old discussion like https://stackoverflow.com/questions/26705554/extend-geom-smooth-in-a-single-direction
If folks need that capability, these days I'd recommend that they fit the model themselves.
@teunbrand gave me a heads up about this issue, so dropping in another possible (bespoke?) pedagogical xseq use, of adding fitted values of the observed values of x as points along smooth line. And also segments between these fitted values and raw data, giving residuals:
mtcars |>
ggplot(aes(wt, mpg)) +
geom_point() +
geom_smooth() +
stat_smooth(geom = "point", # draw fitted values as points
color = "blue",
xseq = mtcars$wt) +
stat_smooth(geom = "segment", # draw residuals
color = "darkred",
xseq = mtcars$wt,
xend = mtcars$wt,
yend = mtcars$mpg)