Search code examples
rplotglmnet

R: Remove top axis title base plot


I want to remove or rename the "top axis title" of the following plot based on the package plotmo. Here is a short reproducible example:

library(glmnet)
library(plotmo)
data(mtcars)

fit <- glmnet(x=as.matrix(mtcars[,-1]), y=as.matrix(mtcars[,1]))
plot_glmnet(fit)

Results in:

enter image description here

It looks like, that the plot is made by base plot functions. May someone knows a way to Change the top axis title or remove it


Solution

  • The only way I could achieve what you desire is by editing the source code.

    plot_glmet.edited<- plot_glmnet ## copy the function
    as.list(body(plot_glmet.edited)) ## print the lines of the function
    

    At the moment the code will not print a label, replace NA with any character string that you want as a title

        body(plot_glmet.edited)[[33]] <- substitute(
             mtext(NA, side = 3, line = 1.5, cex = par("cex") * par("cex.lab")))
    

    enter image description here