0

Run-on question following this problem setting axis widths in gbm.plot; I'm now using plot.gbm directly and don't seem to be able to remove the y axis label, which seems to be set within the plot.gbm function code.

png(filename="name.png",width=4*480, height=4*480, units="px", pointsize=80, bg="white", res=NA, family="", type="cairo-png")
par(mar=c(2.6,2,0.4,0.5), fig=c(0,1,0.1,1), las=1, lwd=8, bty="n", mgp=c(1.6,0.5,0))
plot.gbm(my_gbm_model,1,return.grid=FALSE, write.title=F,lwd=8, ylab=F, axes=F, ylabel=FALSE, ylabel="")
      axis(1, lwd.ticks=8, lwd=8, labels=FALSE) 
      axis(2, lwd.ticks=8, lwd=8, labels=NA, ylab=FALSE,ylabel=FALSE) 
dev.off()

Result: yaxislabel

The y axis label is still there despite all my atempts to remove it through par and plot and axis. I could try burrowing into the function and changing this (and similar) lines:

print(stripplot(X1 ~ temp | X2 * X3, data = X.new, 
    xlab = x$var.names[i.var[i[1]]], 
    ylab = paste("f(", paste(x$var.names[i.var[1:3]], collapse = ","), ")", sep = ""),
    ...))

...but I've been advised against such practices. Any thoughts why this might be working? Simply that the function overrides the setting?

Reproducibility:

#core data csv: https://drive.google.com/file/d/0B6LsdZetdypkWnBJVDJ5U3l4UFU
#(I've tried to make these data reproducible before and I can't work out how to do so)
library(dismo)
samples <- read.csv("data.csv", header = TRUE, row.names=NULL) 
my_gbm_model <- gbm.step(data=samples, gbm.x=1:6, gbm.y=7, family = "bernoulli", 
    tree.complexity = 2, learning.rate = 0.01, bag.fraction = 0.5)
Community
  • 1
  • 1
dez93_2000
  • 1,730
  • 2
  • 23
  • 34

1 Answers1

3

The problem is that plot.gbm just isn't a very R-like function. Since anyone can submit a package to CRAN it's not required that they follow traditional R patterns and that looks like what happened here. If you step though plot.gbm with your sample data, you see that ultimately the plotting is done with

plot(X$X1, X$y, type = "l", xlab = x$var.names[i.var], ylab = ylabel)

and the ylabel is set immediately before with no option to disable it. The authors simply provided no standard way to suppress the ylab for this particular plotting function.

In this case the easiest way might just be to reduce the left margin so the label prints off the plot. Seems like

par("mar"=c(5,2.2,4,2)+.1, fig=c(0,1,0.1,1), las=1, lwd=8, bty="n")
plot.gbm(my_gbm_model,1,return.grid=FALSE, write.title=F,lwd=8, ylab="", axes=F)
axis(1, lwd.ticks=8, lwd=8, labels=FALSE) 
axis(2, lwd.ticks=8, lwd=8, labels=FALSE) 

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295