[R] Possible x-axis label bug in barplot() when "plot = F"

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon May 20 16:10:06 CEST 2002


[forgot to CC to R-help]

Marc Schwartz wrote:
> 
> Hi all,
> 
> I have searched the R-help archives and the bug tracking system and
> could not find this one. I am hoping that someone can either reproduce
> this or tell me that I am missing a step that is the proximate cause.
> 
> I am running R 1.5.0 Patched (May 15, 2002 compiled version kindly
> distributed by Prof. Ripley) under WinXP Pro on a P4m platform, which is
> up to date with all current patches. The display device is a UXGA 1600 x
> 1200 LCD panel running in 32 bit mode. If additional HW information is
> required, let me know.
> 
> The issue appears to be the horizontal positioning of the x-axis labels
> when "plot = F" in barplot().
> 
> The following simple code segments, if reproducible, should help
> demonstrate:
> 
> > plot.new()
> > midpts <- barplot(1:10, axes = F, axisnames = F)
> > axis(1, at = midpts)
> 
> The above code results in a barplot with no axis labels initially.  The
> call to axis() then results in appropriate x-axis labels under the
> midpts of the vertical bars. The x-axis labels are the midpts values.
> 
> > plot.new()
> > midpts <- barplot(1:10, axes = F, axisnames = F, plot = F)
> > axis(1, at = midpts)
> 
> The above code, now with "plot = F", results in a barplot with no bars
> or axis labels initially.  When I call axis(), the first axis label
> ("0.7") is offset well to the right, such that it is the only label
> displayed.
> 
> Am I missing a step that sets the x-axis scaling when "plot = F" or is
> this a bug?

The help page says "plot: logical. If FALSE, nothing is plotted."
barplot() just calculates the midpoints it would use in the case of
plot=TRUE.

In your second example a device is opened by plot.new(), which has the
default user coordinates par("usr")
[1] -0.04  1.04 -0.04  1.04
and the result of your call to axis() is expected.

So plot.new() is useless in either of your examples. In the first one
barplot() generates a new plot anyway, in the second example it makes
axis() work on a way, you don't want it to work ...

The real question (at least for me) is: What are you going to do with
your code?

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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