Search code examples
rplotgam

Is there any method can set different labels with plot.gam?


I am trying to plot my gam result. I want to turn the labels of the plots into Chinese. But, the x label will be used for all plots. How to creat different x-labels for different plots? fit <- gam(happiness ~ s(age) + s(edu) + s(mobility), family = octa(R=5), data = data) plot(fit, xlab = c("年龄","教育”))


Solution

  • You could simply change the column names, not sure how to do this in Chinese though.

    library(mgcv)
    set.seed(2) ## simulate some data... 
    dat <- gamSim(1,n=400,dist="normal",scale=2)[1:3]
    names(dat)[2:3] <- c("ONE", "TWO")
    b <- gam(y~s(ONE)+s(TWO),data=dat)
    plot(b,pages=1,residuals=TRUE)  ## show partial residuals
    

    enter image description here