Hi, I'd like to use R to produce the following plot: dotplot.jpeg <http://r.789695.n4.nabble.com/file/n4672628/dotplot.jpeg> This was constructed using StatKey at: http://www.lock5stat.com/statkey/bootstrap_1_quant/bootstrap_1_quant.html <http://www.lock5stat.com/statkey/bootstrap_1_quant/bootstrap_1_quant.html> The data used was AtlantaCommute (Time) and I generated 1000 bootstrap samples of size 500 with replacement. I'd really like to learn how to make such a dotplot in R. Any thoughts? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Dot-plot-similar-to-StatKey-tp4672628.html Sent from the R help mailing list archive at Nabble.com.
Dot plot similar to StatKey
6 messages · David Arnold, Jim Lemon, S Ellison +2 more
On 07/30/2013 04:21 PM, David Arnold wrote:
Hi, I'd like to use R to produce the following plot: dotplot.jpeg<http://r.789695.n4.nabble.com/file/n4672628/dotplot.jpeg> This was constructed using StatKey at: http://www.lock5stat.com/statkey/bootstrap_1_quant/bootstrap_1_quant.html <http://www.lock5stat.com/statkey/bootstrap_1_quant/bootstrap_1_quant.html> The data used was AtlantaCommute (Time) and I generated 1000 bootstrap samples of size 500 with replacement. I'd really like to learn how to make such a dotplot in R. Any thoughts?
Hi David, Have a look at the dotplot.mtb function in plotrix. Jim
I'd like to use R to produce the following plot: dotplot.jpeg <http://r.789695.n4.nabble.com/file/n4672628/dotplot.jpeg>
x<-rnorm(500)
xr <- round(x, 1)
stripchart(xr, method="stack", pch=19)
will do this if the data are rounded appropriately. You may have some fun with 'appropriately'.
Tinker with ylim to get the axis limits right; stripchart's baseline is at 1 for a single group.
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
geom_dotplot() in the ggplot2 package perhaps? ggplot(mtcars, aes(x = mpg)) + geom_dotplot() John Kane Kingston ON Canada
-----Original Message----- From: dwarnold45 at suddenlink.net Sent: Mon, 29 Jul 2013 23:21:26 -0700 (PDT) To: r-help at r-project.org Subject: [R] Dot plot similar to StatKey Hi, I'd like to use R to produce the following plot: dotplot.jpeg <http://r.789695.n4.nabble.com/file/n4672628/dotplot.jpeg> This was constructed using StatKey at: http://www.lock5stat.com/statkey/bootstrap_1_quant/bootstrap_1_quant.html <http://www.lock5stat.com/statkey/bootstrap_1_quant/bootstrap_1_quant.html> The data used was AtlantaCommute (Time) and I generated 1000 bootstrap samples of size 500 with replacement. I'd really like to learn how to make such a dotplot in R. Any thoughts? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Dot-plot-similar-to-StatKey-tp4672628.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.
____________________________________________________________ GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails
I said:
stripchart(xr, method="stack", pch=19)
will do this if the data are rounded appropriately. You may have some fun with 'appropriately'.
A bit of tinkering gives something that gets close to 'appropriate' (below); you may want to tinker with the tuning factor (or, of course, write something entirely different).
#
# Based on ?points: For 'pch' in '0:25' the default size is about
# 75% of the character height (see 'par("cin")')
round.pch<-function(x, tune=1.0) {
#produces data rounded to approximate graphics symbol width
is.window <- !is.null(dev.list()[1])
if(is.window) {
psize.ins <- 0.75 * par("cin")[2]/(2 * tune)
psize.usr <- psize.ins*diff(par("usr")[1:2] / par("pin")[1])
} else {
psize.usr <- diff(range(pretty(x))) * 0.15 / (14 * tune)
#0.15 is the default par("cin")[2] * 0.75
}
return( psize.usr * (floor(x/psize.usr) + 0.5) )
}
set.seed(73)
x<-rnorm(500)
stripchart(round.pch(x), method="stack", pch=19, ylim=c(0.9,2))
round.pch above uses a vaguely reasonable default rounding with no graphics device present and will use the present device size and units if you have already called plot.new and set user coordinates. Odd things wll happen with a device open and no user coordinates set. Calling this repeatedly with no xlim set in stripchart will cause results to vary visibly as the user coordinates change slightly for each call.
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
I would use panel.dotplot.tb from the HH package.
It is based on lattice, hence will plot multiple groups on the same scale.
continuing with S Ellison's example
## install.packages("HH") ## if necessary
library(HH)
rpx <- round.pch(x)
dotplot( ~ rpx, panel=panel.dotplot.tb, ylim=c(.98, 1.15))
dotplot( ~ rpx | factor(rep(1:2, each=250)), panel=panel.dotplot.tb,
layout=c(1,2), ylim=c(.98, 1.15))
Rich
On 7/30/13, S Ellison <S.Ellison at lgcgroup.com> wrote:
I said:
stripchart(xr, method="stack", pch=19)
will do this if the data are rounded appropriately. You may have some fun with 'appropriately'.
A bit of tinkering gives something that gets close to 'appropriate' (below);
you may want to tinker with the tuning factor (or, of course, write
something entirely different).
#
# Based on ?points: For 'pch' in '0:25' the default size is about
# 75% of the character height (see 'par("cin")')
round.pch<-function(x, tune=1.0) {
#produces data rounded to approximate graphics symbol width
is.window <- !is.null(dev.list()[1])
if(is.window) {
psize.ins <- 0.75 * par("cin")[2]/(2 * tune)
psize.usr <- psize.ins*diff(par("usr")[1:2] / par("pin")[1])
} else {
psize.usr <- diff(range(pretty(x))) * 0.15 / (14 * tune)
#0.15 is the default par("cin")[2] * 0.75
}
return( psize.usr * (floor(x/psize.usr) + 0.5) )
}
set.seed(73)
x<-rnorm(500)
stripchart(round.pch(x), method="stack", pch=19, ylim=c(0.9,2))
round.pch above uses a vaguely reasonable default rounding with no graphics
device present and will use the present device size and units if you have
already called plot.new and set user coordinates. Odd things wll happen with
a device open and no user coordinates set. Calling this repeatedly with no
xlim set in stripchart will cause results to vary visibly as the user
coordinates change slightly for each call.
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
______________________________________________ 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.