[R] Layers in graphs
René Capell
rene.ca at web.de
Tue Jul 15 13:31:39 CEST 2008
Hi Thomas,
without really knowing how your plot looks like: You could try to redraw the first plot in the same device, i.e.:
#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))
#direct into open device
par(new=T)
#again your histogram
hist(weights$Weight, freq=TRUE, breaks=breakpoints, main=wfiles[i])
cheers, René
> -----Ursprüngliche Nachricht-----
> Von: "Thomas Fröjd" <tfrojd at gmail.com>
> Gesendet: 15.07.08 13:07:45
> An: r-help at r-project.org
> Betreff: [R] Layers in graphs
> 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
>
> ______________________________________________
> 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.
>
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066
More information about the R-help
mailing list