R:删除顶轴标题底图

R: Remove top axis title base plot

我想根据包 plotmo 删除或重命名以下绘图的 "top axis title"。这是一个简短的可重现示例:

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

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

结果:

看起来,该图是由基本图函数绘制的。可能有人知道更改顶轴标题或删除它的方法

我能实现您想要的唯一方法是编辑源代码。

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

目前代码不会打印标签,请将 NA 替换为您想要的任何字符串作为标题

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