[R] line width (all elements) in Trellis

2006-11-06 Thread Daniel E. Bunker
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.

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

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

__
R-help@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.


Re: [R] line width (all elements) in Trellis

2006-11-06 Thread Deepayan Sarkar
On 11/6/06, Daniel E. Bunker [EMAIL PROTECTED] 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.

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@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.


Re: [R] line width (all elements) in Trellis

2006-11-06 Thread Paul Murrell
Hi


Deepayan Sarkar wrote:
 On 11/6/06, Daniel E. Bunker [EMAIL PROTECTED] 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@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
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.


Re: [R] line width (all elements) in Trellis

2006-11-06 Thread Deepayan Sarkar
On 11/6/06, Paul Murrell [EMAIL PROTECTED] wrote:
 Hi


 Deepayan Sarkar wrote:
  On 11/6/06, Daniel E. Bunker [EMAIL PROTECTED] 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

__
R-help@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.


Re: [R] line width (all elements) in Trellis

2006-11-06 Thread Daniel E. Bunker
Great!  Thanks to both Paul and Deepayan for these efficient approaches!

-Dan



Deepayan Sarkar wrote:
 On 11/6/06, Paul Murrell [EMAIL PROTECTED] wrote:
 Hi


 Deepayan Sarkar wrote:
  On 11/6/06, Daniel E. Bunker [EMAIL PROTECTED] 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

__
R-help@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.