[R] barp {plotrix} Start bars at 0 with a vector of positive values
Jim Lemon
jim at bitwrit.com.au
Sat Jun 14 07:03:46 CEST 2014
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
More information about the R-help
mailing list