László
László

Reputation: 4144

overriding axis labels after plot in R -- not working if plotting an scb object?

What should I check about the object I plot to be able to override the axis labels, which remain variable names generated be the scb call instead of my specification below? scb is in the locfit library: http://cran.r-project.org/web/packages/locfit/locfit.pdf

fit2<-scb(closed_rule ~ lp(bl),deg=1,xlim=c(0,1),ev=lfgrid(100), family='binomial',alpha=cbind(0,0.3),kern="parm")
pdf('figure1.pdf')
plot(fit2,ylab = "Predicted closed rule probability", xlab="Lobbyist bias", xlim=c(0,1), ylim=c(0,1))
dev.off()

I found no relevant object of fit2 to override -- and I am not even sure why this should be necessary if I specify labels myself. I see one called varnames, that has a single element corresponding to the future x-axis label, but overriding it does not help my labels show, and the ylabel is definitely coming from some completely other place anyway.

Upvotes: 1

Views: 1851

Answers (1)

David R.
David R.

Reputation: 864

The axis labels are kind of predefine in the plot.scb function.

If you type > plot.scb you will see that either plot.scb.1d or plot.scb.2d are used.

plot.scb.1d use the content of fit2$vnames[1] for the x axis. To change the ylab value you will have to hack the function by replacing the plot line in plot.scb.1d by something like that:

...
plot(x$xev, fit, type = "l", ylim = yl, ylab = "Predicted closed rule probability", xlab="Lobbyist bias")
...

For plot.scb.2d it is easier xlab=fit2$vnames[1] and ylab=fit2$vnames[2]. Here, I would change the value(s) of fit2$vnames.

Upvotes: 2

Related Questions