On 02/16/2012 05:22 AM, Colin Wahl wrote:
Thank you,
Its looking like your package will work for me. I have two questions.
First, how do I rotate the plot 90 degrees so the group labels are on
the x axis and the response value on the y axis?
Second, I'm having trouble with the group labels. I need to order my
groups into meaningful groups to properly display my data. I used the
sort.segs=FALSE argument expecting it to plot the values in the order
of data in the plant_height matrix.
centipede.plot(t(plant_height[,c(3,2,4)]),
panel.first=c(abline(h=1: 13 , col="lightgray", lty=2),
abline(v=mean(plant_height$est), col="lightgray")),
sort.segs=FALSE,
left.labels=plant_height$group, bg="green",
right.labels=rep("", 13), xlab="Mean plant height (cm) +- SE")
Not only are the groups not plotted in the order as they appear in the
matrix, but the labels are incorrect. The labels cycle through CA-I,
CAIII, CA-II, in that order.
The plot file is attached.
Hi Colin,
First, I'm mildly amazed that centipede.plot will accept embedded
function commands like lattice graphics. Unsorted groups are plotted
starting from the bottom of the plot, so when I call centipede.plot like
this:
centipede.plot(t(plant_height[,c(3,2,4)]),sort.segs=FALSE,
left.labels=plant_height$group, bg="green",
hgrid=1:13,vgrid=mean(plant_height$est),
right.labels=rep("", 13),
xlab="Mean plant height (cm) +- SE")
I get what I would expect, except for the fact that in modifying the
function, I got the wrong dimension of the "segs" matrix to order the
left.labels, thus the repeating labels. I have fixed that particular bug
and attached the line that fixes the bug for you. I'll wrap up a new
package to fix this for others who may use it.
The big problem is that you want an entirely different plot if you turn
it sideways. What you want in that case is probably:
plot(1:13,plant_height$est,xaxt="n",xlab="Groups",type="n",
ylab="Mean plant height (cm) +- SE",ylim=c(0,20),
main="Plant height by group")
abline(v=1:13,col="lightgray",lty=2)
abline(h=mean(plant_height$est),col="lightgray")
points(1:13,plant_height$est,pch=21,bg="green")
dispersion(1:13,plant_height$est,plant_height$upper,plant_height$lower,
intervals=FALSE)
staxlab(1,at=1:13,labels=plant_height$group)
To fix the label bug, replace this line:
else seg.order<-1:segdim[1]
with this:
else seg.order<-1:segdim[2]
Now that's better.
Jim
______________________________________________
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.