Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values
Hi Jim, Yes, it seems to work. Thanks. Regards, Pascal On Sat, Jun 14, 2014 at 2:03 PM, Jim Lemon 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values
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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values
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 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values
Hi Jorge, It is in order to have different barplots with the same range of limits, to keep them easily comparable. Some have negative values, some others no. Pascal On Fri, Jun 13, 2014 at 7:11 PM, Jorge I Velez wrote: > Hi Pascal, > > Perhaps I am missing something, but what about changing passing ylim = c(0, > 10) to barp()? > > Best, > Jorge.- > > > On Fri, Jun 13, 2014 at 7:50 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. >> >> Regards, >> Pascal >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values
Hi Jim, Thank you for the suggestion. I will try it. Pascal On Fri, Jun 13, 2014 at 7:09 PM, Jim Lemon 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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values
Hi Pascal, Perhaps I am missing something, but what about changing passing ylim = c(0, 10) to barp()? Best, Jorge.- On Fri, Jun 13, 2014 at 7:50 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. > > Regards, > Pascal > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barp {plotrix} Start bars at 0 with a vector of positive values
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 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] barp {plotrix} Start bars at 0 with a vector of positive values
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. Regards, Pascal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.