R 使用plot.gam标记参数术语的轴

R 使用plot.gam标记参数术语的轴,r,plot,gam,R,Plot,Gam,我正在尝试绘制我的gam结果。打印对于所有平滑项(在我的例子中是项1到项8)都非常有效,但是如果我想打印参数项(从9开始),我不能更改轴标签。无论我使用plot、plot.gam、termplot还是text,我都不能这样做。有什么建议吗?下面是代码示例 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,s

我正在尝试绘制我的gam结果。打印对于所有平滑项(在我的例子中是项1到项8)都非常有效,但是如果我想打印参数项(从9开始),我不能更改轴标签。无论我使用plot、plot.gam、termplot还是text,我都不能这样做。有什么建议吗?下面是代码示例

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轴标签,必须使用
xlab
而不是
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="")
require(mgcv)

pa如果您使用的是RStudio,您可以通过点击
F2
按钮来检查
plot.gam
的源代码。在R中,执行不带括号的
plot.gam
。然后您可以发现,对于某些
select
值,将
plot()
替换为
termplot()
。 因此,要操作x轴标签,必须使用
xlab
而不是
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="")
require(mgcv)

pa您可以提供一些可复制的数据(例如,
dput()
)以及您编辑问题时使用的其他软件包。您好,下面是一个示例。当然,示例中的模型没有意义,但问题仍然存在:我无法更改参数术语(术语B)的轴标签:要求(mgcv)pa您能否提供一些可复制的数据(例如,
dput()
)以及编辑问题时使用的其他包。您好,下面是一个示例。当然,示例中的模型没有意义,但问题仍然存在:我无法更改参数术语(术语B)的轴标签:需要(mgcv)pa Genius,它可以工作!!!非常感谢你,我还没想过要检查一下房间code@MagdaChu不客气。请考虑通过点击左边的检查按钮来接受答案。谢谢。您知道如何使用termplot()指定xlim和ylim吗?似乎对我不起作用…应该根据
?termplot
工作。搜索
ylim
Genius,它可以工作!!!非常感谢你,我还没想过要检查一下房间code@MagdaChu不客气。请考虑通过点击左边的检查按钮来接受答案。谢谢。您知道如何使用termplot()指定xlim和ylim吗?似乎对我不起作用…应该根据
?termplot
工作。搜索
ylim