[R] Bar graph with 2 Y axis

Jim Lemon jim at bitwrit.com.au
Fri Mar 16 09:17:07 CET 2012


On 03/16/2012 09:24 AM, KAYIS Seyit Ali wrote:
> Dear R users,
>
> I need to draw a barplot with 2 Y axis. I have 3 days each of wich having 2 groups (and error bar for each of them). The height of the 3rd day is too tall compared to others. That's why I have to use a second Y axis for that. I am using  "barplot2" function of "gplots" library (to be able to add error bars as well). Data and  codes currently I am using is below.
> ...
> Any help regarding adding second Y axis is deeply apprecited.
>
Hi Seyit,
It is fairly easy to get the bars like this:

library(plotrix)
barpos<-barp(means,ylim=range(means+SEM)+c(0,4),col=2:3)
dispersion(barpos$x,barpos$y,CIU,CIL,interval=FALSE)

or even more simply:

dispersion(barpos$x,barpos$y,SEM)

I am not sure that you need an extra y axis here.

Jim



More information about the R-help mailing list