[R] Densities in legend

Daniel En-Wenn Ho deho at fas.harvard.edu
Fri Oct 18 21:42:55 CEST 2002


Hello all,

Does anyone know how to add densities of a histogram to a legend?

I have tried to label five histograms with the following code, to no
avail -- each time, the legend symbol is simply blank.

postscript("graph9.eps")
title=c("Comparison of Quintiles")
hist(quant1$pre,xlim=c(260,310),ylim=c(0,12),ylab="Frequency",xlab="Cholesterol",density=10,main=title)
hist(quant2$pre,add=TRUE,density=20)
hist(quant3$pre,add=TRUE,density=30)
hist(quant4$pre,add=TRUE,density=40)
hist(quant5$pre,add=TRUE,density=50)
legend(260,12,density=c(10,20,30,40,50),legend=c("Quintile 1","Quintile 2","Quintile 3","Quintile 4","Quintile 5"))
dev.off()

Many thanks,

Dan

daniel_ho at harvard.edu



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list