Re: [R] How to overlap two density plots?

From: Jared O'Connell <>
Date: Sat, 26 Apr 2008 13:49:40 +0200

Very nšively, you could do something like this,


, and tinker your xlim and ylim as suitable. The Cairo library gives a pretty example,

plot(Petal.Length, rep(-0.03,length(Species)), xlim=c(1,7),

          ylim=c(0,1.7), xlab="Petal.Length", ylab="Density",
          pch=21, cex=1.5, col="#00000001", main = "Iris (yet again)",
for (i in 1:3) polygon(density(Petal.Length[unclass(Species)==i],bw=0.2),col=c("#ff000040","#00ff0040","#0000ff40")[i]) mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sat 26 Apr 2008 - 11:53:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 26 Apr 2008 - 13:30:33 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive