Hi, I'm looking for some ideas on how to reproduce the attached image in R. There are three samples, each of size n = 10. The first is drawn from a normal distribution with mean 60 and standard deviation 3. The second is drawn from a normal distribution with mean 65 and standard deviation 3. The third is drawn from a normal distribution with mean 70 and standard deviation 3. http://r.789695.n4.nabble.com/file/n4636399/IMG_1306.jpg Any ideas? Thanks. David. -- View this message in context: http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399.html Sent from the R help mailing list archive at Nabble.com.
Side by side strip charts
9 messages · Gerrit Eichner, Peter Dalgaard, David Arnold +3 more
Hi, Arnold, looking at the example section of ?stripchart may help you. Hth -- Gerrit
On Thu, 12 Jul 2012, darnold wrote:
Hi, I'm looking for some ideas on how to reproduce the attached image in R. There are three samples, each of size n = 10. The first is drawn from a normal distribution with mean 60 and standard deviation 3. The second is drawn from a normal distribution with mean 65 and standard deviation 3. The third is drawn from a normal distribution with mean 70 and standard deviation 3. http://r.789695.n4.nabble.com/file/n4636399/IMG_1306.jpg Any ideas? Thanks. David. -- View this message in context: http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
On Jul 13, 2012, at 08:18 , darnold wrote:
Hi, I'm looking for some ideas on how to reproduce the attached image in R. There are three samples, each of size n = 10. The first is drawn from a normal distribution with mean 60 and standard deviation 3. The second is drawn from a normal distribution with mean 65 and standard deviation 3. The third is drawn from a normal distribution with mean 70 and standard deviation 3. http://r.789695.n4.nabble.com/file/n4636399/IMG_1306.jpg Any ideas?
What an excellent homework exercise... stripchart() will do it if it gets a list() of vectors and you set the method= right. Notice that points won't stack unless exactly equal, so round()ing is required.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
OK, got this far:
x1 <- round(rnorm(10,60,3))
x2 <- round(rnorm(10,65,3))
x3 <- round(rnorm(10,70,3))
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1)
Any ideas on how to get an axes drawn under each one as in the image?
Thanks.
David Arnold
College of the Redwoods
http://msemac.redwoods.edu/~darnold/index.php
--
View this message in context: http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399p4636464.html
Sent from the R help mailing list archive at Nabble.com.
try something like abline(h=1.9) John Kane Kingston ON Canada
-----Original Message-----
From: dwarnold45 at suddenlink.net
Sent: Fri, 13 Jul 2012 09:54:35 -0700 (PDT)
To: r-help at r-project.org
Subject: Re: [R] Side by side strip charts
OK, got this far:
x1 <- round(rnorm(10,60,3))
x2 <- round(rnorm(10,65,3))
x3 <- round(rnorm(10,70,3))
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1)
Any ideas on how to get an axes drawn under each one as in the image?
Thanks.
David Arnold
College of the Redwoods
http://msemac.redwoods.edu/~darnold/index.php
--
View this message in context:
http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399p4636464.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
On Jul 13, 2012, at 18:54 , darnold wrote:
OK, got this far:
x1 <- round(rnorm(10,60,3))
x2 <- round(rnorm(10,65,3))
x3 <- round(rnorm(10,70,3))
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1)
Any ideas on how to get an axes drawn under each one as in the image?
I'd expect axis(....., pos=something) to be your friend.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Hello,
Or maybe the argument 'pos' of axis().
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1,
xlim=c(53, 77),
xaxt="n")
axis(1, at = seq(55, 75, by=5), lwd=2)
axis(1, at = seq(55, 75, by=5), pos=1.90, lwd=2)
axis(1, at = seq(55, 75, by=5), pos=2.90, lwd=2)
(I've also added xlim)
Hope this helps,
Rui Barradas
Em 13-07-2012 19:24, John Kane escreveu:
try something like abline(h=1.9) John Kane Kingston ON Canada
-----Original Message-----
From: dwarnold45 at suddenlink.net
Sent: Fri, 13 Jul 2012 09:54:35 -0700 (PDT)
To: r-help at r-project.org
Subject: Re: [R] Side by side strip charts
OK, got this far:
x1 <- round(rnorm(10,60,3))
x2 <- round(rnorm(10,65,3))
x3 <- round(rnorm(10,70,3))
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1)
Any ideas on how to get an axes drawn under each one as in the image?
Thanks.
David Arnold
College of the Redwoods
http://msemac.redwoods.edu/~darnold/index.php
--
View this message in context:
http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399p4636464.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! ______________________________________________ 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.
On 2012-07-13 11:37, Rui Barradas wrote:
Hello,
Or maybe the argument 'pos' of axis().
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1,
xlim=c(53, 77),
xaxt="n")
axis(1, at = seq(55, 75, by=5), lwd=2)
axis(1, at = seq(55, 75, by=5), pos=1.90, lwd=2)
axis(1, at = seq(55, 75, by=5), pos=2.90, lwd=2)
(I've also added xlim)
Hope this helps,
Rui Barradas
It seemed like a good exercise to try to imitate the plot
posted by the OP (on Nabble) a bit more closely; so here's
my attempt:
## x-axis values to print
myat <- seq(55, 75, 5)
## adjust plot margins to accommodate side 4 labels
par(mar = c(4,2,2,6), oma = rep(1,4))
## do the plot without axes or frame
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method = "stack",
pch = 4,
offset = 1/2,
col = "blue",
lwd = 2,
xlim = c(53, 77),
axes = FALSE)
## add the axes; tcl=-0.5 is the default; not really needed
axis(1, at = myat, tcl = -0.5)
axis(1, at = myat, pos = 1.90, tcl = -0.5)
axis(1, at = myat, pos = 2.90, tcl = -0.5)
## reprint the axes without labels; ticks are upward
axis(1, at = myat, labels = NA, tcl = 0.5)
axis(1, at = myat, labels = NA, pos = 1.90, tcl = 0.5)
axis(1, at = myat, labels = NA, pos = 2.90, tcl = 0.5)
## do the right-side axis, labels only
axis(4, at = (1:3)-0.1,
labels = paste("Sample",1:3), las = 1, lwd = 0)
## extend horizontal axis lines
abline(h = (1:3)-0.1, lwd = 2)
## add the frame; it's in a bit from the outer edges
## due to the 'oma=' par setting
box("figure")
Peter Ehlers
Em 13-07-2012 19:24, John Kane escreveu:
try something like abline(h=1.9) John Kane Kingston ON Canada
-----Original Message-----
From: dwarnold45 at suddenlink.net
Sent: Fri, 13 Jul 2012 09:54:35 -0700 (PDT)
To: r-help at r-project.org
Subject: Re: [R] Side by side strip charts
OK, got this far:
x1 <- round(rnorm(10,60,3))
x2 <- round(rnorm(10,65,3))
x3 <- round(rnorm(10,70,3))
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1)
Any ideas on how to get an axes drawn under each one as in the image?
Thanks.
David Arnold
College of the Redwoods
http://msemac.redwoods.edu/~darnold/index.php
--
View this message in context:
http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399p4636464.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! ______________________________________________ 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.
______________________________________________ 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.
Very nice suggestion. I am getting some very kind help here.
x1 <- round(rnorm(10,60,3))
x2 <- round(rnorm(10,65,3))
x3 <- round(rnorm(10,70,3))
stripchart(list(sample1=x1,sample2=x2,sample3=x3),
method="stack",
pch=4,
offset=1/2,
col="blue",
lwd=2,
las=1,
xlim=c(50,80))
axis(1,pos=2.9,labels=FALSE)
axis(1,pos=1.9,labels=FALSE)
http://r.789695.n4.nabble.com/file/n4636502/Rplot.png
Thanks.
David Arnold
College of the Redwoods
--
View this message in context: http://r.789695.n4.nabble.com/Side-by-side-strip-charts-tp4636399p4636502.html
Sent from the R help mailing list archive at Nabble.com.