[R] Rectangle height in lattice xyplot key
Duncan Mackay
mackay at northnet.com.au
Tue Jan 11 12:11:46 CET 2011
Hi Deepayan
Thank you very much for the update to lattice and the solution.
For the current problem the texts are all single lines and the solution
works well.
The example was to accentuate the problem and I thought that it would be
useful in the future.
I was able to make all the heights look equal in the example by creating a
vector and reducing the height of the 2-lined rows.
xyplot(1~1,
key = list(corner = c(0.8,0.8),
cex = 0.6,
title = "Functional Groups",
cex.title = 0.7,
columns = 1,
padding.text = 4,
text = list(label =
c("Tree","Shrub\n(low)","Herb","Grass","Shrub\n(small)")),
points = list(pch = c(1,3,4,20,16),
col = c(2,3,4,5,6)),
lines = list(col = c(2,3,4,5,6),
size = 2),
rectangles = list(col = c(2,3,4,5,6),
size = 1,
height = c(0.7,0.45,0.7,0.7,0.45),
border = FALSE)) )
Regards
Duncan
At 17:14 11/01/2011, you wrote:
>On Sun, Jan 9, 2011 at 9:31 AM, Duncan Mackay <mackay at northnet.com.au> wrote:
> > Dear All
> >
> > I have a problem with the height of the boxes in the key in the following.
> > (The text is over 2 lines to Â accentuate the problem of no space
> between the
> > rectangles.)
> > Is there an easy way to put a space between the rectangles; size controls
> > the width but there appears to be nothing for the height?
>
>There is now (in the last update of lattice, released last week). So
>the following should work:
>
>xyplot(1~1,
> key = list(corner = c(0.8,0.8),
> cex = 0.6,
> title = "Functional Groups",
> cex.title = 0.7,
> columns = 1,
> padding.text = 4,
> text = list(label =
>c("Tree","Shrub\n(low)","Herb","Grass","Shrub\n(small)")),
> points = list(pch = c(1,3,4,20,16),
> col = c(2,3,4,5,6)),
> lines = list(col = c(2,3,4,5,6),
> size = 2),
> rectangles = list(col = c(2,3,4,5,6),
> size = 1,
> height = 0.7, ## newly added
> border = FALSE)) )
>
>Of course 'height' is just a multiplier, so the heights are still not
>all the same because of differing row heights, but I assume that's not
>going to be a problem in your real example.
>
>-Deepayan
>
> >
> > Â Â Â Â xyplot(1~1,
> > Â Â Â Â Â key = list(corner = c(0.8,0.8),
> > Â Â Â Â Â Â Â Â Â Â Â cex Â = 0.6,
> > Â Â Â Â Â Â Â Â Â Â Â title = "Functional Groups",
> > Â Â Â Â Â Â Â Â Â Â Â cex.title = 0.7,
> > Â Â Â Â Â Â Â Â Â Â Â columns = 1,
> > Â Â Â Â Â Â Â Â Â Â Â padding.text = 4,
> > Â Â Â Â Â Â Â Â Â Â Â text Â = list(label =
> > c("Tree","Shrub\n(low)","Herb","Grass","Shrub\n(small)")),
> > Â Â Â Â Â Â Â Â Â Â Â points = list(pch = c(1,3,4,20,16),
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â col = c(2,3,4,5,6)),
> > Â Â Â Â Â Â Â Â Â Â Â lines = list(col = c(2,3,4,5,6),
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â size = 2),),
> > Â Â Â Â Â Â Â Â Â Â Â rectangles = list(col = c(2,3,4,5,6),
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â size = 1,
> > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â border =
> FALSE)) )
> >
> > I could get things to work when the legend was on top using
> > Â http://finzi.psych.upenn.edu/R/Rhelp02/archive/46654.html on something
> > similar
> > but could not get it to work in the last panel of a multipanel plot.
> >
> > Regards
> >
> > Duncan Mackay
> > Department of Agronomy and Soil Science
> > University of New England
> > Armidale NSW 2351
> > Email: home mackay at northnet.com.au
> >
> > R version 2.12.1 (2010-12-16)
> > Platform: i386-pc-mingw32/i386 (32-bit)
> >
> > locale:
> > [1] LC_COLLATE=English_Australia.1252 Â LC_CTYPE=English_Australia.1252
> > LC_MONETARY=English_Australia.1252
> > [4] LC_NUMERIC=C
> Â Â Â Â Â Â Â Â Â Â Â LC_TIME=English_Australia.1252
> >
> > attached base packages:
> > [1] splines Â datasets Â utils Â Â stats Â Â graphics Â grDevices grid
> > Â methods Â base
> >
> > other attached packages:
> > Â [1] locfit_1.5-6 Â Â Â Â akima_0.5-4 Â Â Â Â lme4_0.999375-37
> > Matrix_0.999375-46 Â mgcv_1.7-2
> > Â [6] geepack_1.0-17 Â Â Â doBy_4.1.2 Â Â Â Â Â contrast_0.13
> Design_2.3-0
> > Â Â Hmisc_3.8-3
> > [11] survival_2.36-2 Â Â gee_4.13-16 Â Â Â Â R2HTML_2.2
> Â Â Â Â Â zoo_1.6-4
> > Â Â Â Â gsubfn_0.5-5
> > [16] proto_0.3-8 Â Â Â Â RODBC_1.3-2 Â Â Â Â gtools_2.6.2
> xtable_1.5-6
> > Â R.oo_1.7.4
> > [21] R.methodsS3_1.2.1 Â foreign_0.8-41 Â Â Â chron_2.3-39 MASS_7.3-9
> > Â latticeExtra_0.6-14
> > [26] RColorBrewer_1.0-2 Â lattice_0.19-13
> >
> > loaded via a namespace (and not attached):
> > [1] cluster_1.13.2 nlme_3.1-97 Â Â stats4_2.12.1 Â tools_2.12.1
> >
> > ______________________________________________
> > R-help at r-project.org 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.
> >
More information about the R-help
mailing list