Re: [R] Layers in graphs

From: René Capell <rene.ca_at_web.de>
Date: Tue, 15 Jul 2008 13:31:39 +0200


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

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:35:23 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 - 13:31:44 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