[R] Dot plot similar to StatKey

Richard M. Heiberger rmh at temple.edu
Tue Jul 30 21:04:50 CEST 2013


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.
>



More information about the R-help mailing list