[R] modify tick labels in 3D GAM plot

Suzan Pool Suzan.Pool at noaa.gov
Fri Jun 29 19:45:15 CEST 2007


Hello,

I have a GAM plot in 3D which was generated from the mgcv package 
(plot.gam) which seems to call the persp( ) function from graphics.  
This plot is one of three being plotted in the graphics window to copy 
to a manuscript.  The plot's rotation has been set to clearly show the 
response surface generated in GAM.  The resulting plot is small enough 
that the tick labels overlap tick marks, start in the plot, and overlap 
each other.  I could reduce the font size using cex, however, doing so 
would make it too small for the manuscript.  Using adj in par( ) does 
not change anything in the plot.gam( ) function, only the text( ) 
function.  The tick labels on the x-axis need adjustment to the right 
and those on the y-axis need adjustment to the left.
 
Here is the code:

library(mgcv)
gam.from.mgcv<-gam(response ~ s(var1) + s(var2, var3) + s(var4) + 
offset(var5),
    family=poisson, scale=-1, gamma=1.4, data=globecdata)
par(mfrow=c(1,3))
par(cex=1, xpd=NA)
plot(gam.from.mgcv, select=2, pers=T, theta=-65, phi=20, scale=0,
      xlab="\n\n\nLongitude", ylab="\n\nLatitude", main="",
      ticktype="detailed", expand=0.8)
par(srt=100, adj=0.5)  #angle and alignment to set for z label
text(-0.5,-0.06,"Effect\n\n")  #x,y coordinates to place z label
 
How do I adjust the tick labels?
 
Also, I would like to remove the negative signs from the tick labels on 
the x-axis for longitude.  Is there a way to use the abs( ) function for 
this?
 
Thanks,
Suzan

-- 
Suzan Pool
Oregon State University
Cooperative Institute for Marine Resources Studies



More information about the R-help mailing list