[R] Possible x-axis label bug in barplot() when "plot = F"
Marc Schwartz
MSchwartz at medanalytics.com
Tue May 21 17:58:59 CEST 2002
> -----Original Message-----
> From: owner-r-help at stat.math.ethz.ch [mailto:owner-r-
> help at stat.math.ethz.ch] On Behalf Of Uwe Ligges
> Sent: Tuesday, May 21, 2002 3:02 AM
> To: MSchwartz at medanalytics.com
> Cc: 'R-Help List'
> Subject: Re: [R] Possible x-axis label bug in barplot() when "plot =
F"
>
> Sorry for answering so late. I was quite busy the during last days.
> I don't know exactly why the argument plot=FALSE was introduced to
> barplot(), obviously the author only tried to get the midpoints, but
not
> the behaviour of plot() with argument type="n".
>
> Nevertheless, it is possible to extend barplot() to get the desired
> behaviour.
> Since I have not the time to try it out, let's see it as an exercise:
> Change the following lines in barplot.default() from
>
> if (plot) {
> opar <- if (horiz)
> par(xaxs = "i", xpd = xpd)
> else par(yaxs = "i", xpd = xpd)
> on.exit(par(opar))
> plot.new()
> plot.window(xlim, ylim, log = "", ...)
> xyrect <- ...
>
> to
> opar <- if (horiz)
> par(xaxs = "i", xpd = xpd)
> else par(yaxs = "i", xpd = xpd)
> on.exit(par(opar))
> plot.new()
> plot.window(xlim, ylim, log = "", ...)
> if (plot) {
> xyrect <- ...
>
> i.e. just open a new device and set up the window dimensions in any
case
> (even with plot=FALSE).
> Whether it is a bug or a feature is not clear to me ...
>
> Uwe Ligges
Uwe,
Again, thanks for your reply and no apology required. I have tried to
be very sensitive to both the value of this forum and the time of the
group. I recognize that most folks (me included) have other
responsibilities that demand their time. Thus I spent many hours of my
own time this weekend searching the forums, reading books and
documentation (including S-Plus, where barplot() does not appear to have
a "plot=" argument) trying to figure this one out and what I was doing
wrong before I posted. As a consequence, I am very appreciative of your
interaction on this particular issue.
To your point, it was my expectation of consistent behavior between
barplot() and plot() when no plotting actually occurred, that led me
astray.
Had I taken the additional time to review the R source code for
barplot(), I probably would have realized that when "plot=F", given
where the boolean check for (plot) is located in the code, the display
device in fact does not get configured as apparently it does in plot()
when type="n".
In the future, I shall endeavor to review the source code in similar
situations which in this case, would have saved me many headaches. If I
should forget to do so, please virtually throw something at me.
I have created a new function temporarily called MYbarplot() using a
MYbarplot method with the modification you indicated above and it does
appear to work (without extensive testing) as desired. If anyone should
be interested in this, I would be happy to e-mail a copy.
I am not sure what the formal procedure is for a request enhancement (I
did search a bit) but if reasonable, perhaps a global option for the
plot region color (ie. par(pr = "color") )could be introduced such that
each of the plotting functions would be able to utilize this parameter.
In that way the higher level plotting functions (ie. barplot, boxplot,
etc.) could be used to accomplish what now requires calls to the lower
level component functions. I presume that such a change is entirely
non-trivial and as such may be appropriate for a major version update
some time down the road.
Again, thanks for your support.
Marc
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list