[R] dotplots with error bars
Colin Wahl
biowahl at gmail.com
Wed Feb 15 19:22:31 CET 2012
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.
Colin
On Mon, Feb 13, 2012 at 1:31 AM, Jim Lemon <jim at bitwrit.com.au> wrote:
> On 02/13/2012 09:51 AM, Colin Wahl wrote:
>>
>> Does anyone have any recommendations for producing dotplots with error
>> bars? Are there packages available for this? I searched far and wide
>> and cannot find a suitable option.
>>
>> I am trying to produce publication-quality figures for my thesis
>> results. Dotplots (Cleveland dotplots) are a much better form of
>> summarizing barchart-type data. It does not appear that any of the
>> main plotting packages in r support dotplots with error bars.
>> Considering the benefit of these plots, I find it difficult to believe
>> that they have not been fully integrated into R.
>>
>> I did find a function "dotplots.errors" available here:
>> http://agrobiol.sggw.waw.pl/~cbcs/articles/CBCS_5_2_2.pdf.
>>
>> However, I have found this function absurdly difficult to use when
>> customizing figures (ordering displays properly, or just simple
>> getting the function to work.)
>>
>> I've been struggling for the last few hours to figure out the error:
>> "error using packet 1 sum not meaningful for factors." Unlike other
>> packages, this function doesnt have a ?dotplots.errors to help guide
>> troubleshooting. I presume this is a technicality due to the a numeric
>> variable being identified as a factor. However, I've double checked
>> that all the numeric columns in the data frame are not factors, and
>> the error persists.
>>
>> I'd really prefer not just calling it quits and resorting to
>> old-school sloppy bar charts, but if thats what I need to do to finish
>> this in a timely manner, then so be it.
>>
> Hi Colin,
> I am grateful that Marcin Kozak gave plotrix a plug in the paper, and to
> show my gratitude, I'll explain how to use centipede.plot to get the
> illustration in the paper. Assume that you have the data frame shown on p70
> of the paper:
>
> plant_height<-read.csv("plant_height.csv")
>
> Now, to echo Marcin, let us produce the plot:
>
> library(plotrix)
> centipede.plot(t(plant_height[,c(3,2,4)]),
> left.labels=plant_height$group,bg="black",
> right.labels=rep("",13),xlab="Mean plant height (cm) +- SE")
>
> If you want the mean value line:
>
> abline(v=mean(plant_height$est),col="lightgray")
>
> The grid lines are a bit more difficult. You could insert a line into the
> function just after the call to box() to draw grid lines under each dot:
>
> abline(h=1:dim(x)[2],col="lightgray",lty=2)
>
> However, this looks like such a good idea that I will add two arguments to
> the function to do the vertical line(s) and horizontal grid automatically,
> and this option will appear in the next version of plotrix.
>
> Jim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plantheight.png
Type: image/png
Size: 28225 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120215/92b74464/attachment.png>
More information about the R-help
mailing list