[R] Creating a flat legend 'grob' for lattice xyplot

Gesmann, Markus Markus.Gesmann at lloyds.com
Wed Jul 27 19:45:03 CEST 2011


Hi Mark,

I believe the argument you are looking for is column not ncol.
Try the following:

library(lattice)
xyplot(1~1,
auto.key=list(
bty='n',
pch=rep(c(15,17),2),
col=c('brown','green','blue','red'),
columns=4,      
text=c('How','to make','this into', 'a grob?'),
space="top"
))

 
Regards

Markus

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Mark
Sent: 27 July 2011 18:32
To: r-help at r-project.org
Subject: [R] Creating a flat legend 'grob' for lattice xyplot

Hi,

I want my xyplot legend to be flat, not tall, and there seems to be no way for xyplot's auto.key and key elements to do this: I tried many, many permutations of what I could find in the archives and reading the documentation.  If there there's a way to make it flat, please tell me what the magic incantation is.

Here's a simple example of what I like to see.  The xyplot will be a multi-panelled one with a single, flat legend below.  It seems the xyplot's legend element is the way to go -- the option I haven't tried because I don't know what or how to create a grob of this kind.  Where to start?

xyplot(1~1)
legend(0.15,-0.125,
bty='n',pch=rep(c(15,17),2),col=c('brown','green','blue','red'),ncol=4,
          legend=c('How','to make','this into', 'a grob?'))

Thanks!



--
View this message in context: http://r.789695.n4.nabble.com/Creating-a-flat-legend-grob-for-lattice-xyplot-tp3699235p3699235.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
**********************************************************************
The information in this E-Mail and in any attachments is...{{dropped:27}}



More information about the R-help mailing list