[R] lattice: aligning independent graphs

From: Zack Weinberg <zack_at_cogsci.ucsd.edu>
Date: Sat, 26 May 2007 16:39:56 -0700


I find myself wanting to plot three graphs side by side 'as if' they were panels -- that is, with the same y-axis limits, no space between the graphs, and precise vertical alignment of the plot areas. However, I don't want strip titles; I want each graph to have its own x-axis label, on the bottom of the plot.

The best way I have so far found to do this is to fake up a data frame that allows me to use actual panels, turn off the strip, and insert a whole bunch of white space in the x-axis label so it looks like there are three separate labels. Like this:

xyplot(x ~ thing | panel,

       data=wrong.all,
       ylab=list(label='% incorrect responses', cex=0.7),
       xlab=list(label=paste('Trial number                                 ',

'Subject number ',
'Experimental condition'), cex=0.7),
ylim=c(0,top), col='black', pch=3, strip=F, scales=list( x=list(alternating=c(1,0), tck=c(1,0), cex=0.5, rot=90, relation='free', at=list( seq(0,33,by=5), seq(0,maxsub, by=5), seq(1,length(levels(wrongconds)))), labels=list(seq(0,33,by=5), seq(0,maxsub, by=5), levels(wrongconds))), y=list(at=seq(0,top,by=10), alternating=c(1,0), tck=c(1,1), cex=0.5)), type=list(c('p','smooth'), 'h', 'h'), panel=function(..., type=list("p")) { panel.grid(h=-1, v=0) panel.xyplot(..., type=type[[panel.number()]])
})

But surely there is a better way?

zw



R-help_at_stat.math.ethz.ch 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. Received on Sat 26 May 2007 - 23:45:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 May 2007 - 22:31:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.