[R] Layers in graphs
Thomas Fröjd
tfrojd at gmail.com
Tue Jul 15 13:05:21 CEST 2008
Hi,
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])
#lines(dens)
polygon(dens$x, dens$y, border=NA, col=rgb(1,0,1,0.5))
/Thomas
More information about the R-help
mailing list