Skip to content
Prev 256635 / 398506 Next

Override col.lines and col.symbol in panel.xyplot with type='b'

Thanks Deepayan. I've been burnt before trying base graphics idioms in lattice graphics, so never even thought to try that.  Although I am not sure I would have figured out the row vs. group distinction without diving deeply into the source.

Apologies for my obtuseness; I have however learned quite a bit with both my own tinkerings and this advice.  Thanks again.  -John

-----Original Message-----
From: Deepayan Sarkar [mailto:deepayan.sarkar at gmail.com] 
Sent: Tuesday, 12 April, 2011 3:31 AM
To: Szumiloski, John
Cc: r-help at r-project.org
Subject: Re: [R] Override col.lines and col.symbol in panel.xyplot with type='b'
On Mon, Apr 11, 2011 at 9:27 PM, Szumiloski, John <john_szumiloski at merck.com> wrote:
No, it does not. You are making things unnecessarily complicated.

When you use 'groups', colors are associated with levels of the grouping variable, not individual rows of your data. So:

set.seed(388659262)
dat <- data.frame(Panel=rep(c('A','B'), each=4),
                  ID=factor(rep(letters[1:4], each=2)),
                  X=rep(c(0,1), times=4),
                  Y=runif(8))

##### now for the arbitrary colors.  Let's highlight one subject red, the rest black

myColor <- ifelse(levels(dat$ID) == "a", 2, 1)

xyplot(Y ~ X | Panel, data=dat, groups=ID,
       type='b', col = myColor,
       scales=list(x=list(at=c(0,1),labels=c(0,1))))

-Deepayan
Notice:  This e-mail message, together with any attachme...{{dropped:11}}