[Rd] missing axes in irregular lattice plots (PR#9556)

bill at insightful.com bill at insightful.com
Wed Mar 7 21:31:36 CET 2007

In the lattice functions, if the first or last
panel in a row or column is not at the edge of the array
of panels there will be no axis drawn for that row or column,
except that when the said panel is the last in the array
its right y axis will be drawn.  For example,
 > d<-data.frame(x=1:20, y=1:20, g=rep(LETTERS[1:4],len=20))
 > library(lattice)
 > bwplot(floor(x/8)~y|g, layout=c(1,3), as.table=T, data=d)
That bwplot() call should make 2 pages of panels with 3 panels
on page 1 and 1 panel on page 2.  The single panel on the second
page has x tick marks at its top edge, but no tick marks or
labels below it.  Thus you have to look at the first page of
panel to determine the x scale.

In the second example (using the same data.frame) there
are no x or y tick labels for any panel.
 > xyplot(y~x|g, layout=c(3,3), skip=c(T,T,F, F,F,T, T,F,T), as.table=T, data=d)
This example is rather contrived, but might arise when one
wants to omit panels with no data in them but to leave a
hole in the array for unused factor levels in the given

Exactly the same problem happens in S-Plus.  I patched it to
put an axis on the first and last panels in each row and
column, instead of only on the plots in position 1 and nrow
(or ncol) of each row and column.

One might also fix it by putting axes all around the array of
plots, at the edge of the array.  Perhaps you only want axes
on rows and columns that have at least one plot in them.

One might prefer to only attack the layout(1,n),as.table=T
problem by making sure the last plot has x axis tick labels
associated with it, just as the last plot always gets y
axis tick labels associated with it.

Bill Dunlap
Insightful Corporation
bill at insightful dot com

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."

--please do not edit the information below--

 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = Under development (unstable)
 major = 2
 minor = 5.0
 year = 2007
 month = 02
 day = 05
 svn rev = 40659
 language = R
 version.string = R version 2.5.0 Under development (unstable) (2007-02-05 r40659)


Search Path:
 .GlobalEnv, package:lattice, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base

More information about the R-devel mailing list