I'm trying to create a dotplot with some grouping. 

I've been able to create what I want using dotchart (basic graphics), but can't 
quite get it using dotplot (lattice). I prefer to use lattice (or ggplot2) 
because I think it's a bit easier to control some other aspects of the plot 
appearance. 

Basically, w/ lattice I've not been able to get the y-axis label to include the 
group variable. 

I'd like... 

A 
1 
2 
B 
1 
2 
3 
4 
C 
1 
2 
3 

I'm getting... 
1 
2 
1 
2 
3 
4 
1 
2 
3 

The following example code illustrates.... 

set.seed(18) 
dta <- data.frame(var1=factor(c("A", "A", "B", "B", "B", "B", "C", "C", "C")), 
var2=c(1,2,1,2,3,4,1,2,3), 
var3=round(runif(9,1,10),1), 
plotorder=9:1) 

dta 

windows(3,3) 
dotchart(dta$var3[order(dta$var1, -dta$var2)], groups=dta$var1, 
labels=dta$var2[order(dta$var1, -dta$var2)], cex=.75, 
gcolor=c("blue", "red", "dark green"), 
col=c(rep("blue",2), rep("red",4), rep("dark green",3)), 
axes=NULL) 


windows(3,3) 
dotplot(data=dta, plotorder~var3, groups=var1, col=c("blue", "red", "dark 
green"), 
scales=list(y=list(labels=dta$var2[order(dta$plotorder)]))) 

Thanks. 

Marc 
R 2.13.0 (2011-04-13) 
Windows XP 


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to