[R] line width (all elements) in Trellis

Paul Murrell p.murrell at auckland.ac.nz
Mon Nov 6 21:28:01 CET 2006


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()

Paul



> I can't decide yet if the current behaviour is desirable, so it might
> change in future.
> 
> -Deepayan
> 
>> Code with a barchart() example is below.  Any advice would be greatly
>> appreciated.
>>
>> Thanks for your time,
>>
>> Dan
>>
>> note: I am using R 2.4.0 on a windows platform.
>>
>>
>> windows(width=6, height=4, record=TRUE)
>>
>> tpar1=trellis.par.get("add.line")
>> tpar1$lwd=2
>> trellis.par.set("add.line", tpar1)
>>
>> tpar2=trellis.par.get("plot.polygon")
>> tpar2$lwd=2
>> trellis.par.set("plot.polygon", tpar2)
>>
>> tpar3=trellis.par.get("plot.line")
>> tpar3$lwd=2
>> trellis.par.set("plot.line", tpar3)
>>
>> tpar4=trellis.par.get("superpose.polygon")
>> tpar4$lwd=c(rep(2,7))
>> trellis.par.set("superpose.polygon", tpar4)
>>
>> tpar5=trellis.par.get("superpose.line")
>> tpar5$lwd=c(rep(2,7))
>> trellis.par.set("superpose.line", tpar5)
>>
>> tpar6=trellis.par.get("axis.line")
>> tpar6$lwd=c(rep(2,7))
>> trellis.par.set("axis.line", tpar6)
>>
>> tpar7=trellis.par.get("box.3d")
>> tpar7$lwd=2
>> trellis.par.set("box.3d", tpar7)
>>
>> tpar8=trellis.par.get("box.rectangle")
>> tpar8$lwd=2
>> trellis.par.set("box.rectangle", tpar8)
>>
>> tpar9=trellis.par.get("box.umbrella")
>> tpar9$lwd=2
>> trellis.par.set("box.umbrella", tpar9)
>>
>> tpar10=trellis.par.get("dot.line")
>> tpar10$lwd=2
>> trellis.par.set("dot.line", tpar10)
>>
>> tpar11=trellis.par.get("strip.border")
>> tpar11$lwd=c(rep(2,7))
>> trellis.par.set("strip.border", tpar11)
>>
>> tpar12=trellis.par.get("reference.line")
>> tpar12$lwd=c(rep(2,7))
>> trellis.par.set("reference.line", tpar12)
>>
>>
>> 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)))
> 
> ______________________________________________
> 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.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list