mfasiolo / mgcViz

An R package for interactive visualization of GAM models
https://mfasiolo.github.io/mgcViz/
76 stars 9 forks source link

add horizontal line #58

Closed madsurgeon closed 5 years ago

madsurgeon commented 5 years ago

Hi, is there a way to add a horizontal line to each graph in print(plot(b, allTerms = T), pages = 1) ? I would be interested to display a horizontal line at 0 in each of the graphs. Thanks!

mfasiolo commented 5 years ago

Hi, you should use geom_hline as in the following example:

library(mgcViz)
set.seed(2) ## simulate some data...
dat <- gamSim(1,n=1000,dist="normal",scale=2)

# Fit GAM and get gamViz object
b <- gamV(y~x0+s(x1)+ s(x2)+s(x3), data = dat, 
          aGam = list(scale = 2), aViz = list("nsim" = 20))

print(plot(b, allTerms = TRUE) + geom_hline(yintercept = 0, col = "grey"), pages = 1)
madsurgeon commented 5 years ago

Thank you very much!