[英]labeling axis for parametric terms with plot.gam
我正在尝试绘制我的游戏结果。 对于所有平滑项(在我的情况下为1到8),该绘制效果都很好,但是如果要绘制参数项(从9开始),则无法更改轴标签。 无论我使用plot,plot.gam,termplot还是文本,我都无法做到。 有小费吗? 下面是代码示例
par(mfrow=c(3,3), oma=c(1,1,1,1),pty="s",mar=c(4.5,4.5,1,1))
# the first three graphs work perfectly
plot.gam(model$gam,select=1,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Water depth",ylab="")
plot.gam(model$gam,select=2,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Bottom current speed",ylab="")
plot.gam(model$gam,select=3,scale=0,pers=TRUE,all.terms=T,shade=T,xlab="Substance",ylab="")
# this graph for the parametric term is plotted but I cannot change axis labels
plot.gam(model$gam,select=9,scale=0,pers=T,all.terms=T,shade=T,xlab="AIS",ylab="")
如果您使用的是RStudio,则可以通过按F2
按钮来检查plot.gam
的源代码。 在R中执行不带括号的plot.gam
。 然后您会发现,对于某些select
值, plot()
被termplot()
代替。 因此,要操纵x轴标签,您必须使用xlabs
而不是xlab
。
require(mgcv)
pa <- c(1, rep(0, 9))
term_A <- runif(10, 9, 15)
term_B <- runif(10, 1, 25)
data <- as.data.frame(cbind(pa, term_A, term_B))
mod <- gam(pa ~ s(term_A, k=3) + term_B, family=binomial, data=data)
summary(mod)
par(mfrow=c(2, 2))
# xlab=""
plot.gam(mod, select=1, all.terms=T, shade=T, xlab="your own lab title", ylab="")
# xlabs=""
plot.gam(mod, select=2, all.terms=T, shade=T, xlabs="your own lab title", ylab="")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.