[R] barp {plotrix} Start bars at 0 with a vector of positive values

Pascal Oettli kridox at ymail.com
Sat Jun 14 05:57:12 CEST 2014


Hi Jim,

I tried your fix.

This one works:
barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))

This one fails:
barp(c(2,3,4,5,6,7,8))

Regards,
Pascal

On Fri, Jun 13, 2014 at 7:09 PM, Jim Lemon <jim at bitwrit.com.au> wrote:
> On Fri, 13 Jun 2014 06:50:59 PM Pascal Oettli wrote:
>> Dear list,
>>
>> Please consider the following example:
>>
>> library(plotrix)
>> barp(c(2,3,4,5,6,7,8), ylim=c(-10,10))
>>
>> How to force the bars to start at 0? I could not find the way to do it.
>>
> Hi Pascal,
> You are right, I had not considered the idea of setting a negative y limit
> when there were no negative values. I think you can fix this by changing:
>
>  negy<-any(height<0,na.rm=TRUE)
>
>  to
>
> negy<-any(height<0,na.rm=TRUE) || ylim[1] < 0
>
> I'll check this later (I'm just going out) and if it doesn't work, I'll send
> another email with something that does.
>
> Jim
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan



More information about the R-help mailing list