Skip to content
Prev 120410 / 398500 Next

multiple rugs on a single plot

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