[R] Multiple Legends on a densityplot

Ken Beath kbeath at efs.mq.edu.au
Mon Oct 17 09:09:52 CEST 2005


I am trying to obtain multiple legends on a densityplot, using the  
legend parameter. I am trying the following code, with just one  
legend at the moment, which doesn't work. I get

Error in valid.data(rep(units, length.out = length(x)), data) :
     No 'grob' supplied for 'grobwidth' unit

Fixable or better method ? What I need is a separate legend for each  
panel.

densityplot(~lclassprob | cov,
     groups=group,
     main='Density Plot for Covariates',
     xlab='Class probability (Logistic)',
     plot.points=FALSE,
     layout=c(1,6),
     legend=list(inside=list(corner=c(0,0),x=0, y=0, fun=simpleKey,
         args=list(text= c("Yes","No"), points = FALSE,
           rectangles = FALSE,
           lines = TRUE))),
     data=newcapsCov2)




More information about the R-help mailing list