in a similar fashion, would it be possible to have the "rug points" on the
density line itself instead of on the x-axis?
thanks in advance,
Albert.
On 7/17/07, Dimitris Rizopoulos
wrote:
>
> you could use different colours, e.g.,
>
> x1 <- rnorm(100, -2.5, 1)
> x2 <- rnorm(100, 0, 1)
> x3 <- rnorm(100, 2.5, 1)
> x <- c(x1, x2, x3)
>
> plot(density(x))
> rug(x1, col = "red")
> rug(x2, col = "black")
> rug(x3, col = "blue")
>
> or something like the following:
>
> plot(density(x))
> len <- 0.005
> ds <- 0.001
> segments(x1, -1, x1, 0)
> segments(x2, 0 + ds, x2, len)
> segments(x3, len + ds, x3, 2*len)
>
>
> I hope it helps.
>
> Best,
> Dimitris
>
> ----
> Dimitris Rizopoulos
> Ph.D. Student
> Biostatistical Centre
> School of Public Health
> Catholic University of Leuven
>
> Address: Kapucijnenvoer 35, Leuven, Belgium
> Tel: +32/(0)16/336899
> Fax: +32/(0)16/337015
> Web: http://med.kuleuven.be/biostat/
> http://www.student.kuleuven.be/~m0390867/dimitris.htm
>
>
> ----- Original Message -----
> From: "Quin Wills"
> To:
> Sent: Tuesday, July 17, 2007 12:50 PM
> Subject: [R] multiple rugs on a single plot
>
>
> > Hi
> >
> >
> >
> > I could only find some discussion on this wrt lattice graphics
> > (which I'm
> > not using). Apologies if I'm missing something obvious.
> >
> >
> >
> > I'd like to produce 3 rug plots under a kernel density plot for a
> > population. The population is subdivided into 3 subpopulations,
> > which I'd
> > like the rug plots to highlight. Naturally, when I do 3 rug plots,
> > they all
> > plot over each other. I'd like 3 parallel rug plots along the
> > x-axis. But
> > how.
> >
> >
> >
> > Thanks in advance,
> >
> > Quin
> >
> >
> >
> >
> >
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch 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.
> >
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
[[alternative HTML version deleted]]