The following single line of code shows what I am trying to do, and the problem I am having... barplot(c(101,102,103),ylim=c(100,103)) The 'xaxis' is missing, and the grey bars 'fall off' the plot area. This is generally ugly, and I would like to trim the bars (ideally they would have a ragged appearance to show that I am 'zooming in'). I can see why what I am trying to do is conceptually a bit tricky, as the yaxis needs to be closly inspected to see the data in its propper context. This is simply fixed by showing... barplot(c(101,102,103)) However, I want to first show the data in its propper context, then 'zoom in' to highlight the difference between the bars. I tried covering up the bottom of the chart with a rect() command, but it wont draw ouside the area highlighted with the box command, for example barplot(c(101,102,103),ylim=c(100,103)) box() rect(0.7,0,1.9,102.5,col="white") So I can't work out how to stop bars falling off the end of the plot, so my labels are being written on the bars. How can I fix this?
How about approaching it this way? > barplot(c(1,2,3), ylim=c(0,3), yaxt="n") > axis(side=2, at=c(0,1,2,3), labels=seq(100,103,1)) Dan Bolser wrote:> > The following single line of code shows what I am trying to do, and the > problem I am having... > > barplot(c(101,102,103),ylim=c(100,103)) > > The 'xaxis' is missing, and the grey bars 'fall off' the plot area. This > is generally ugly, and I would like to trim the bars (ideally they would > have a ragged appearance to show that I am 'zooming in'). > > I can see why what I am trying to do is conceptually a bit tricky, as the > yaxis needs to be closly inspected to see the data in its propper context. > This is simply fixed by showing... > > barplot(c(101,102,103)) > > However, I want to first show the data in its propper context, then 'zoom > in' to highlight the difference between the bars. > > I tried covering up the bottom of the chart with a rect() command, but it > wont draw ouside the area highlighted with the box command, for example > > > barplot(c(101,102,103),ylim=c(100,103)) > box() > rect(0.7,0,1.9,102.5,col="white") > > So I can't work out how to stop bars falling off the end of the plot, so > my labels are being written on the bars. > > How can I fix this? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 452-1424 (M, W, F) fax: (917) 438-0894
On Fri, 2005-02-18 at 14:47 +0000, Dan Bolser wrote:> > The following single line of code shows what I am trying to do, and the > problem I am having... > > barplot(c(101,102,103),ylim=c(100,103)) > > The 'xaxis' is missing, and the grey bars 'fall off' the plot area. This > is generally ugly, and I would like to trim the bars (ideally they would > have a ragged appearance to show that I am 'zooming in'). > > I can see why what I am trying to do is conceptually a bit tricky, as the > yaxis needs to be closly inspected to see the data in its propper context. > This is simply fixed by showing... > > barplot(c(101,102,103)) > > However, I want to first show the data in its propper context, then 'zoom > in' to highlight the difference between the bars. > > I tried covering up the bottom of the chart with a rect() command, but it > wont draw ouside the area highlighted with the box command, for example > > > barplot(c(101,102,103),ylim=c(100,103)) > box() > rect(0.7,0,1.9,102.5,col="white") > > So I can't work out how to stop bars falling off the end of the plot, so > my labels are being written on the bars. > > How can I fix this?Dan, Try this: barplot(c(101,102,103),ylim=c(100,103), xpd = FALSE) Note that the setting of par("xpd") clips the bars outside the plot region. See ?par for more information. HTH, Marc Schwartz
Dan Bolser wrote:> > The following single line of code shows what I am trying to do, and the > problem I am having... > > barplot(c(101,102,103),ylim=c(100,103)) > > The 'xaxis' is missing, and the grey bars 'fall off' the plot area. This > is generally ugly, and I would like to trim the bars (ideally they would > have a ragged appearance to show that I am 'zooming in'). > > I can see why what I am trying to do is conceptually a bit tricky, as the > yaxis needs to be closly inspected to see the data in its propper context. > This is simply fixed by showing... > > barplot(c(101,102,103))So you want to turn clipping on using xpd=FALSE, e.g. something like bp <- barplot(c(101,102,103), ylim=c(100,103), xpd=FALSE) axis(1, at=bp, labels=1:3) Uwe Ligges> However, I want to first show the data in its propper context, then 'zoom > in' to highlight the difference between the bars. > > I tried covering up the bottom of the chart with a rect() command, but it > wont draw ouside the area highlighted with the box command, for example > > > barplot(c(101,102,103),ylim=c(100,103)) > box() > rect(0.7,0,1.9,102.5,col="white") > > So I can't work out how to stop bars falling off the end of the plot, so > my labels are being written on the bars. > > How can I fix this? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
I think a workaround, that will do what you want is: barplot(c(101,102,103) - 100, offset = 100) hth, Z On Fri, 18 Feb 2005 14:47:24 +0000 (GMT) Dan Bolser wrote:> > > The following single line of code shows what I am trying to do, and > the problem I am having... > > barplot(c(101,102,103),ylim=c(100,103)) > > The 'xaxis' is missing, and the grey bars 'fall off' the plot area. > This is generally ugly, and I would like to trim the bars (ideally > they would have a ragged appearance to show that I am 'zooming in'). > > I can see why what I am trying to do is conceptually a bit tricky, as > the yaxis needs to be closly inspected to see the data in its propper > context. This is simply fixed by showing... > > barplot(c(101,102,103)) > > However, I want to first show the data in its propper context, then > 'zoom in' to highlight the difference between the bars. > > I tried covering up the bottom of the chart with a rect() command, but > it wont draw ouside the area highlighted with the box command, for > example > > > barplot(c(101,102,103),ylim=c(100,103)) > box() > rect(0.7,0,1.9,102.5,col="white") > > So I can't work out how to stop bars falling off the end of the plot, > so my labels are being written on the bars. > > How can I fix this? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >