[R] Layers in graphs

From: Thomas Fröjd <tfrojd_at_gmail.com>
Date: Tue, 15 Jul 2008 13:05:21 +0200


I am trying to plot a distribution over a histogram with the polygon() function. However I have to use this function after hist() and that makes the polygon cover the histogram. I would prefer having the histogram at the top layer and the polygon as the background. Is that possible?

A workaround is to use pdf and set transparency but that still makes the histogram wrongly colored since the part covered by the transparant polygon is obfuscated.

Any help is very welcome, here is my code so far.

#graph it

hist(weights$Weight, freq=TRUE, breaks=breakpoints, main=wfiles[i])


polygon(dens$x, dens$y, border=NA, col=rgb(1,0,1,0.5))


R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 15 Jul 2008 - 11:08:12 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 Tue 15 Jul 2008 - 12:31:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive