Folkes, Michael
2009-Oct-08 17:52 UTC
[R] lattice: passing multiple lty values to the key/legend
hi all,
It's not clear to me how (or if) I can pass multiple values for lty to a key
in xyplot?
I've tried: lines=list(lty=1:3), to no avail.
Do I need to use something other than auto.key?
(Deepayan, if you're out there, I have your book and must admit the answer
isn't jumping out at me.)
thanks in advance!
Michael Folkes
example code:
#____________________________
xx<-data.frame(v1=rep(letters[1:3],rep(3,3)),v2=rep(1:3,3),v3=rep(1:3,rep(3,3)))
xyplot(v3~v2,data=xx,
xlab='',
group=v1,type='l', lty=1:3 ,
auto.key=list(text = levels(as.factor(xx$v1)) , title='',
cex.title=.75,points=F,lines = T,cex=1, x = .5, y = -0.1,corner = c(0,
0),
between=1,columns=3,between.columns=2),
)
_______________________________________________________
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053 Michael.Folkes@dfo-mpo.gc.ca
<mailto:Michael.Folkes@dfo-mpo.gc.ca>
[[alternative HTML version deleted]]
Peter Ehlers
2009-Oct-08 23:29 UTC
[R] lattice: passing multiple lty values to the key/legend
Try setting lty with par.settings:
xyplot(v3~v2,data=xx,
xlab='',
# group=v1,type='l', lty=1:3 ,
groups=v1, type='l',
par.settings = list(superpose.line = list(lty = 1:3)),
auto.key = list(text=levels(as.factor(xx$v1)) , title='',
cex.title=.75,points=F,lines = T,cex=1,
x = .5, y = -0.1,corner = c(0, 0),
between=1,columns=3,between.columns=2),
)
and since 'v1' should be a factor in xx, you don't need the
as.factor() in auto.key.
-Peter Ehlers
Folkes, Michael wrote:> hi all,
> It's not clear to me how (or if) I can pass multiple values for lty to
a key in xyplot?
> I've tried: lines=list(lty=1:3), to no avail.
> Do I need to use something other than auto.key?
> (Deepayan, if you're out there, I have your book and must admit the
answer isn't jumping out at me.)
> thanks in advance!
> Michael Folkes
>
> example code:
> #____________________________
>
>
xx<-data.frame(v1=rep(letters[1:3],rep(3,3)),v2=rep(1:3,3),v3=rep(1:3,rep(3,3)))
> xyplot(v3~v2,data=xx,
> xlab='',
> group=v1,type='l', lty=1:3 ,
>
> auto.key=list(text = levels(as.factor(xx$v1)) , title='',
> cex.title=.75,points=F,lines = T,cex=1, x = .5, y = -0.1,corner =
c(0, 0),
> between=1,columns=3,between.columns=2),
> )
>
>
> _______________________________________________________
> Michael Folkes
> Salmon Stock Assessment
> Canadian Dept. of Fisheries & Oceans
> Pacific Biological Station
> 3190 Hammond Bay Rd.
> Nanaimo, B.C., Canada
> V9T-6N7
> Ph (250) 756-7264 Fax (250) 756-7053 Michael.Folkes at dfo-mpo.gc.ca
<mailto:Michael.Folkes at dfo-mpo.gc.ca>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
>
Deepayan Sarkar
2009-Oct-10 08:09 UTC
[R] lattice: passing multiple lty values to the key/legend
On Thu, Oct 8, 2009 at 10:52 AM, Folkes, Michael <Michael.Folkes at dfo-mpo.gc.ca> wrote:> hi all, > It's not clear to me how (or if) I can pass multiple values for lty to a key in xyplot? > I've tried: ?lines=list(lty=1:3), to no avail. > Do I need to use something other than auto.key? > (Deepayan, if you're out there, I have your book and must admit the answer isn't jumping out at me.)It's probably not spelled out as clearly as it could have been, but see Section 7.1.6 (p 125). -Deepayan> thanks in advance! > Michael Folkes > > example code: > #____________________________ > > xx<-data.frame(v1=rep(letters[1:3],rep(3,3)),v2=rep(1:3,3),v3=rep(1:3,rep(3,3))) > xyplot(v3~v2,data=xx, > ?xlab='', > ?group=v1,type='l', lty=1:3 ?, > > ? auto.key=list(text = levels(as.factor(xx$v1)) , title='', > ? ? ? ? ?cex.title=.75,points=F,lines = T,cex=1, x = .5, y = -0.1,corner = c(0, 0), > ? ? ? ? ?between=1,columns=3,between.columns=2), > ?) > > > _______________________________________________________ > Michael Folkes > Salmon Stock Assessment > Canadian Dept. of Fisheries & Oceans > Pacific Biological Station > 3190 Hammond Bay Rd. > Nanaimo, B.C., Canada > V9T-6N7 > Ph (250) 756-7264 Fax (250) 756-7053 ?Michael.Folkes at dfo-mpo.gc.ca <mailto:Michael.Folkes at dfo-mpo.gc.ca> > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >
Seemingly Similar Threads
- Floating points and floor() ?
- maptools::sunriset() daylight savings to stardard time change
- RODBC excel - need to preserve (or extract) numeric column names
- Convert week value to date
- Hmisc binconf function value interpretation during narrow confidence intervals