[R] line width (all elements) in Trellis
Deepayan Sarkar
deepayan.sarkar at gmail.com
Mon Nov 6 21:42:14 CET 2006
On 11/6/06, Paul Murrell <p.murrell at auckland.ac.nz> wrote:
> Hi
>
>
> Deepayan Sarkar wrote:
> > On 11/6/06, Daniel E. Bunker <deb37 at columbia.edu> wrote:
> >> Dear All,
> >>
> >> I am hoping to implement a barchart using trellis graphics where all
> >> elements have a line width of 2.
> >>
> >> Using trellis.par.set(), I am able to make most elements lwd=2, but not
> >> all. In particular, the top of the box (above the upper most strip) and
> >> the left y-axis remain one point.
> >
> > Actually, those are lwd=2 too, but half of the lines are getting
> > clipped (this should happen on the right/bottom too, and does in PDF
> > output, for example. Not sure why it's not as clear on screen
> > devices). Anyway, you can add
> >
> > trellis.par.set("clip", list(panel = "off", strip = "off"))
> >
> > and see if that helps you.
>
>
> And instead of all those 'lwd=2' settings, you could just use 'lex=2',
> as in ...
>
>
> library(grid)
> library(lattice)
>
> windows(width=6, height=4, record=TRUE)
>
> trellis.par.set("clip", list(panel = "off", strip = "off"))
>
> pushViewport(viewport(gp=gpar(lex=2)))
> print(barchart(yield ~ variety | site,
> data = barley, groups = year,
> layout = c(1, 6),
> ylab = "Barley Yield (bushels/acre)",
> scales = list(x = list(abbreviate = TRUE,
> minlength = 5))),
> newpage=FALSE)
> upViewport()
Cool! There's also the "grid.pars" trellis.par now for things like
this, so you could also do
trellis.par.set("clip", list(panel = "off", strip = "off"))
trellis.par.set("grid.pars", list(lex = 2))
barchart(yield ~ variety | site,
data = barley, groups = year,
layout = c(1, 6),
ylab = "Barley Yield (bushels/acre)",
scales = list(x = list(abbreviate = TRUE,
minlength = 5)))
-Deepayan
More information about the R-help
mailing list