[R] Two overlaid density plots - Does order matter?
stephen sefick
ssefick at gmail.com
Thu Sep 25 18:22:31 CEST 2008
this is not reproducible, but this may be the answer-- R graphic
devices are like a pen and paper when you plot something it is there
on the piece of paper then when you plot something else on top of that
then if there are any points that intersect with the first plot then
they will be plotted on top of the points from the old graph
plot(1,1)
plot(1,1, col="blue")
On Thu, Sep 25, 2008 at 11:54 AM, Stephen Collins
<Stephen_Collins at aon.com> wrote:
> In the following code, the only difference between the two plots is the
> order the variables are plotted. In this case, the plot of "cdata.den" in
> plot #1 is different from its plot in #2. Specifically, "cdata.den" spans
> the x-axis from -5 to 30 in plot #1 and from 0 to 20 in plot #2. Does
> anyone understand why these two plots do not yield the same result?
>
> #Make density objects
> pre.den<- density(
> preclaims[preclaims[,7]>cc1 & preclaims[,7]<cc2,7],
> from = cc1,
> to = cc2)
> cdata.den<-density(cdata,from=cc1,to=cc2)
>
> #Plot No. 1
> x11()
> plot(cdata.den,col=1)
> lines(pre.den,col=2)
>
> #Plot No. 2
> plot(pre.den,col=2)
> lines(cdata.den,col = 1)
>
> Regards,
>
> Stephen Collins, MPP | Analyst
> Health & Benefits | Aon Consulting
> 200 East Randolph, Suite 900, Chicago, IL
> Tel: 312-381-2578 | Fax: 312-381-0136
> Email: stephen_collins at aon.com
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
--
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.
-K. Mullis
More information about the R-help
mailing list