[R] Lattice Plot formatting problem/s
Peter Ehlers
ehlers at ucalgary.ca
Wed Jan 6 17:11:48 CET 2010
fishman wrote:
> Hi
> I am having difficulty getting the right format for a lattice plot I am
> trying to produce.
>
> Here is a pic of the plot as I get it now
> http://i235.photobucket.com/albums/ee37/scotrivers/lattice_plot01.jpg
>
> and here is the code I am using:
>
> RN<-read.csv("N:/data.dat",header=T)
> DATA<-RN[is.element(RN$age,0:3),] #select data on age
> ogmod1<-glm(mig~age+length,family=binomial(link="logit"),data=DATA)
> design1<-expand.grid(age=c(0:3),length=seq(30,300,by=10))
> design1$pbs<-predict(ogmod1,new=design1,type="response")
> design1$migr<-round(design1$pbs)
> library(lattice)
> wireframe(pbs~age*length,data=design1,aspect=c(1,1),main="Probability
> Surface",
> drape=T,scale=list(arrows=FALSE),screen=list(z=45,x=-75),
> colorkey=list(space="right",height=0.6),xlab="Age",ylab="Length
> (mm)",zlab="Probability")
>
> I have a number of problems:
> 1. the Z-axis label goes off the edge of the plotting area, I need to move
> the plot to the right somehow, but can't find a way to do this (tried
> various margin settings)
Or rotate the z-label; see below.
> 2. I would like the Z scale to read from 0 to 1.0 with intervals of 0.2, at
> the moment there is no 0 or 1.0 on the scale
Use the 'scales' argument; see below.
> 3. I would like the X-axis tick marks to just be 0, 1, 2 & 3. At the moment
> they go up in 0.5 intervals rather than 1.0
Use the 'scales' argument;
You don't provide reproducible code, so here's an example
from ?wireframe; it should give you the idea:
library(lattice)
wireframe(volcano, shade = FALSE,
zlim=c(100,200), ##modify the z-axis limits
zlab=list("long_z_label", rot=90), ##print z-label parallel
scales=list(
arrows=FALSE,
z=list(at=c(100,150,200)), ##where to put ticks and labels
x=list(at=c(10,50,70))))
-Peter Ehlers
>
> I have been searching round for ages for info on these problems, so I hope
> some kind person can help.
> Thanks
--
Peter Ehlers
University of Calgary
403.202.3921
More information about the R-help
mailing list