[R] legend in lattice densityplot

Albert Vilella avilella at gmail.com
Wed Nov 29 18:11:52 CET 2006


Hi,

I have a densityplot like this:

x = c(rnorm(100,1,2),rnorm(100,2,4),rnorm(100,3,6))
f = sample(c("A","B","C","D","E"),300,replace=TRUE)
df=data.frame(x,f)
library(lattice)
attach(df)
densityplot(~x, groups=f)

And I want to add a legend with the colours for the factors. How can I do that?
How can I not have the dots of the distribution at the bottom, or at
least, make them occupy less vertical space?



More information about the R-help mailing list