Hi list, I'm using barplot2 form the gplots package to plot a few numbers (I want to add SD bars later). However, I would like the y-axis not to start from 0 but 500. When I add the parameters YLIM, something goes wrong. The graph is not 'cut off' at 500. Instead the bars seems to sink trough the bottom of the graph. Because its a little hard to explain, here is a self-containing example: library(gplots) ABrt<-c(588,589,593,588) Wrt<-c(580,583,592,612) RT<-rbind(ABrt,Wrt) barplot2(RT,beside=T,col=c('black','white'),ylim=c(500,1000)) Does anybody know of a solution? Regards, Dieter ------------------------------------------ Dieter Vanderelst dieter _ vanderelst AT emailengine DOT org d DOT vanderelst AT tue DOT nl Eindhoven University of Technology Faculty of Industrial Design Designed Intelligence Group Den Dolech 2 5612 AZ Eindhoven The Netherlands Tel +31 40 247 91 11
I'm not sure exactly why it won't work but it could be that conceptually a bar plot starting at 500 does not make a lot of sense and the package writers did not entertain such an idea? I'd suggest having a look at ?dotchart as an alternative why to plot the data or perhaps have a look at errplot() in Hmisc. If you really need a barplot you might have a look at gap.barplot in plotrix. --- Dieter Vanderelst <dieter_vanderelst at emailengine.org> wrote:> Hi list, > > I'm using barplot2 form the gplots package to plot a > few numbers (I want to add SD bars later). > > However, I would like the y-axis not to start from 0 > but 500. When I add the parameters YLIM, something > goes wrong. The graph is not 'cut off' at 500. > Instead the bars seems to sink trough the bottom of > the graph. > > Because its a little hard to explain, here is a > self-containing example: > > > library(gplots) > > ABrt<-c(588,589,593,588) > Wrt<-c(580,583,592,612) > > RT<-rbind(ABrt,Wrt) >barplot2(RT,beside=T,col=c('black','white'),ylim=c(500,1000))> > Does anybody know of a solution? > > Regards, > Dieter > > ------------------------------------------ > Dieter Vanderelst > > dieter _ vanderelst AT emailengine DOT org > d DOT vanderelst AT tue DOT nl > > Eindhoven University of Technology > Faculty of Industrial Design > Designed Intelligence Group > Den Dolech 2 > 5612 AZ Eindhoven > The Netherlands > Tel +31 40 247 91 11 > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >
On Wed, 2007-10-31 at 11:52 +0100, Dieter Vanderelst wrote:> Hi list, > > I'm using barplot2 form the gplots package to plot a few numbers (I > want to add SD bars later). > > However, I would like the y-axis not to start from 0 but 500. When I > add the parameters YLIM, something goes wrong. The graph is not 'cut > off' at 500. Instead the bars seems to sink trough the bottom of the > graph. > > Because its a little hard to explain, here is a self-containing > example: > > > library(gplots) > > ABrt<-c(588,589,593,588) > Wrt<-c(580,583,592,612) > > RT<-rbind(ABrt,Wrt) > barplot2(RT,beside=T,col=c('black','white'),ylim=c(500,1000)) > > Does anybody know of a solution? > > Regards, > DieterThe behavior here is the same for both barplot() and barplot2(). You need to set par("xpd") to FALSE, so that the bars are clipped to the plot region: barplot2(RT,beside=T,col=c('black','white'),ylim=c(500,1000), xpd = FALSE) See ?par That being said, this is a bad idea in general, as you impact the ability to visually discern the relative difference (or lack of it) in the bars. You would be better off using a dotplot. HTH, Marc Schwartz