[R] line width (all elements) in Trellis

Daniel E. Bunker deb37 at columbia.edu
Mon Nov 6 22:49:27 CET 2006


Great!  Thanks to both Paul and Deepayan for these efficient approaches!

-Dan



Deepayan Sarkar wrote:
> 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

-- 
Daniel E. Bunker
BioMERGE Associate Director
Post-Doctoral Research Scientist
Columbia University
Department of Ecology, Evolution and Environmental Biology
1200 Amsterdam Avenue
New York, NY 10027-5557

deb37ATcolumbiaDOTedu
212-851-1888 phone
212-854-8188 fax



More information about the R-help mailing list