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

Pascal Oettli kridox at ymail.com
Sat Jun 14 08:19:39 CEST 2014


Hi Jim,

Yes, it seems to work. Thanks.

Regards,
Pascal

On Sat, Jun 14, 2014 at 2:03 PM, Jim Lemon <jim at bitwrit.com.au> wrote:
> On Sat, 14 Jun 2014 12:57:12 PM you wrote:
>> 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
>>
> Hi Pascal,
> Right again. This seems to work for both and I think handles the problem
> correctly:
>
>  if(is.null(ylim)) {
>   negy<-any(height<0,na.rm=TRUE)
>   if(negy) miny<-min(height,na.rm=TRUE)*1.05
>   else miny<-ifelse(ylog,min(height)/10,0)
>   ylim<-c(miny,max(height,na.rm=TRUE)*1.05)
>  }
>  else {
>   miny<-ylim[1]
>   negy<-miny<0
>  }
>
> Remove the line:
>
> negy<-any(height<0,na.rm=TRUE)
>
> and modify the succeeding conditional clause as above. This will appear
> in version 3.5-8.
>
> Jim
>



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan



More information about the R-help mailing list