我无法在gbm模型的局部图上更改x和y标签.我需要为期刊文章重命名它们.
我读了这个并创建了如下图:
library(gbm)
final<- readRDS(final_gbm_model)
summary(final, n.trees=final$n.trees)
Run Code Online (Sandbox Code Playgroud)
以下是摘要输出:
var rel.inf
ProbMn50ppb ProbMn50ppb 11.042750
ProbDOpt5ppm ProbDOpt5ppm 7.585275
Ngw_1975 Ngw_1975 6.314080
PrecipMinusETin_1971_2000_GWRP PrecipMinusETin_1971_2000_GWRP 4.988598
N_total N_total 4.776950
DTW60YrJurgens DTW60YrJurgens 4.415016
CVHM_TextZone CVHM_TextZone 4.225048
RiverDist_NEAR RiverDist_NEAR 4.165035
LateralPosition LateralPosition 4.036406
CAML1990_natural_water CAML1990_natural_water 3.720303
PctCoarseMFUpActLayer PctCoarseMFUpActLayer 3.668184
BioClim_BIO12 BioClim_BIO12 3.561071
MFDTWSpr2000Faunt MFDTWSpr2000Faunt 3.383900
PBot_krig PBot_krig 3.362289
WaterUse2 WaterUse2 3.291040
AVG_CLAY AVG_CLAY 3.280454
Age_yrs Age_yrs 3.144734
MFVelSept2000 MFVelSept2000 3.064030
AVG_SILT AVG_SILT 2.882709
ScreenLength ScreenLength 2.683542
HydGrp_C HydGrp_C 2.666106
AVG_POR AVG_POR 2.563147
MFVelFeb2000 MFVelFeb2000 2.505106
HiWatTabDepMin HiWatTabDepMin 2.421521
RechargeAnnualmmWolock RechargeAnnualmmWolock 2.252706
Run Code Online (Sandbox Code Playgroud)
我可以创建一个部分依赖图如下:
plot(final,"ProbMn50ppb",n.trees=final$n.trees)
Run Code Online (Sandbox Code Playgroud)
plot(final,"ProbMn50ppb",n.trees=final$n.trees,ylab="LNNO3")
Error in plot.default(X$X1, X$y, type = "l", xlab = x$var.names[i.var], :
formal argument "ylab" matched by multiple actual arguments
Run Code Online (Sandbox Code Playgroud)
如何更改y轴和x轴标签?
该plot.gbm函数将自己的名称传递给通用绘图函数,因此两者相互冲突.因此,您将无法在该模式下以您希望的方式自定义绘图.但是当你设定时,作者确实提供了另一种选择return.grid=TRUE.它不是构建绘图,而是输出数据本身.然后,您可以将其用于包括ggplot2在内的任何绘图.
plotdata <- plot(gbm1, return.grid=TRUE)
plot(plotdata, type="l", ylab="ylab", xlab="xlab")
Run Code Online (Sandbox Code Playgroud)
来自帮助的示例数据(gbm)