簡體   English   中英

使用plot.gam標記參數項的標記軸

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM