[R] Lattice plots and missing x-axis labels on second page

David Winsemius dwinsemius at comcast.net
Fri Nov 4 21:33:55 CET 2011


On Nov 2, 2011, at 8:23 PM, Evans, David G (DFG) wrote:

> I should say I'm using Windows-7, R version 2.13.0 and lattice version
> 0.19-33.  I've pared down my code to this :
>
> pdat = read.table("RGRAPHSDGE.csv",header=T,sep=",",fill=T)
> print(xyplot(pdat$NITRATE~pdat$DATEYR|pdat$WELL,

I generally try to avoid building lattice plots this way. It is better  
to use data=pdat and shorten the formula specification. That way the  
functions can use the aggregate information in the dataframe. Try:

xyplot( NITRATE~ DATEYR| WELL, data=pdat,


> as.table=TRUE,
> layout=c(3,4),

You may want to try layout=c(3,4,2)

See help(xyplot) subsection layout, where Sarkar says that pages are  
somethimes incorrectly calculated.

> xlab="Year",
> ylab="Nitrate mg / litre",
> strip=FALSE
> ))
>
> First 3 lines of pdat looks like this:
>                    WELL   DATEYR NITRATE
> 1 ALASKA CHILDRENS SERVICES 1993.836    0.81
> 2 ALASKA CHILDRENS SERVICES 1994.850    0.91
> 3 ALASKA CHILDRENS SERVICES 1995.803    0.94
> ....
> Thanks again.
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org 
> ]
> On Behalf Of Evans, David G (DFG)
> Sent: Wednesday, November 02, 2011 3:24 PM
> To: r-help at r-project.org
> Subject: [R] Lattice plots and missing x-axis labels on second page
>
> Hello,
> I'm trying to make a lattice plot (using xyplot()). I have included a
> "layout=c(3,4)" statement, giving me 12 plots per page and an
> "as.table=TRUE" statement, directing the way the plots are laid  
> out.  I
> have 18 plots altogether and so 6 of them end up on the second page.



> Everything looks fine for the first page, but the x-axis labels (e.g.
> 1993, 1994...) are all missing on the second page.  The x-axis  
> variable
> name ("Year") is there at the bottom, however.   Any help is
> appreciated. Thanks.
>
> David G. Evans
> Biometrician
> Division of Sport Fish
> Alaska Dept . of Fish and Game
> Anchorage, Ak 99518
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list