pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
61 stars 18 forks source link

Why don't plot arguments work when 'by' is specified? #15

Closed pbreheny closed 8 years ago

pbreheny commented 8 years ago

Joaquín Aldabe (Universidad de la República) writes:

I´d appreciate it if you could tell me how changing axis labels size in visreg, when plotting a conditional variable. I´ve tried cex.axis and cex.labels but it´s not working.

pbreheny commented 8 years ago

When the by argument is specified, visreg uses the lattice package to display the output, which has a different mechanism for specifying graphical options than base R graphics does. So, for example, suppose we fit the model

airquality$Heat <- cut(airquality$Temp,3,labels=c("Cool","Mild","Hot"))
fit.in1 <- lm(Ozone~ Solar.R + Wind*Heat,data=airquality)

If we try this, nothing happens, as you point out:

visreg(fit.in1, "Wind", by="Heat", cex.axis=2)

The reason is that we are trying to use a base R option with a lattice plot. In lattice, the appearance of the axes is controlled through a scales argument, so we need:

visreg(fit.in1, "Wind", by="Heat", scales=list(x=list(cex=2)))

or

visreg(fit.in1, "Wind", by="Heat", scales=list(x=list(cex=2), y=list(cex=2)))

For other graphical parameters, you'll have to read the lattice documentation (or try Googling it).