[R] multiple rugs on a single plot
Quin Wills
wills at stats.ox.ac.uk
Tue Jul 17 15:19:17 CEST 2007
Excellent! Thanks.
-----Original Message-----
From: Dimitris Rizopoulos [mailto:dimitrios.rizopoulos at student.kuleuven.be]
Sent: 17 July 2007 13:40
To: Quin Wills
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] multiple rugs on a single plot
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" <wills at stats.ox.ac.uk>
To: <r-help at stat.math.ethz.ch>
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 at 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.
>
More information about the R-help
mailing list