I'd like to plot the response of a variable within a GAM using visreg. I'm using visreg's gg=TRUE feature in order to specify ggplot theme elements. I turned off partials and set rug = TRUE. However, I'm getting a rug on both the x AND y axis (as opposed to just the x axis). I'm not sure how to turn off the y axis rug while keeping the x axis rug. Here is the code I'm using for the plot:
library(visreg)
visreg(gam, "OISST_Temp_new", partial = FALSE, rug = 2,
line = list(col = "black"),fill = list(fill ="lightblue"), gg=TRUE)+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_blank(),
panel.border = element_rect(linetype = "solid", fill = NA),
text = element_text(size=10, color = "black"),
axis.text = element_text(size = 10, color = "black"))
When I run this code I'm left with this figure:
gam
is an mgcv::gam
object and OISST_Temp_new
is the response I would like to visualize.
When I specify gg=FALSE and just plot the response with rug = TRUE
and partial = FALSE
without any ggplot elements I get the correct x axis rug. Any help would be greatly appreciated!
You can set the relevant layer inside the
ggplot
object toNULL
. Below is the example from thegam
function.