[R] barplot x axis
mschwartz at medanalytics.com
Sat Oct 12 22:46:20 CEST 2002
> -----Original Message-----
> Dear Schwartz and Pausas,
> Thanks for your messages.
You are welcome.
> I was referring to the axis line and its tick marks.
> If you write barplot(table(c(1,2,2,3,3,3,4,4,5))) in R150 and in R160
> have different plots. The last one will not display the x axis line
> marks, but only x axis labels, isn't it?
> In this case "axis(1, at = mp, labels = 1:5)" solves the problem.
> Best regards,
> Antonio Olinto
It turns out that the change in behavior, which I was able to duplicate
by re-installing V1.5.1 on my system, is the result in the change in
coding in the axis() function internal C code (do_axis) in V.1.6.0 and
not in barplot(). The code in barplot() did not change either in
content or in the default argument values.
If you review the C do_axis code in the V1.5.1 plot.c, which is the C
source code for many of the plotting functions, you will find that the
author overrides the passed "lty" argument. The author has a comment in
the C code as follows:
/* I can't think of a good reason to allow axes with a non-solid
* so I override any value the user may have specified.
* This may need to be revisited, but this should
* cover 99.99% of the cases. */
In barplot(), the following code is called to draw the label axis (x
axis when horiz = FALSE):
else 1, at = at.l, labels = names.arg, lty = 0, cex.axis =
Note that the 'lty' argument is specified as "0", which should be
"blank" or no line.
However, the V1.5.x internal C code in plot.c overrides this value with
"solid" as per the author's comments above. Thus in V.1.5.x, you get a
solid line on the x axis.
In V.1.6.0, there was a change in axis() to allow for the user
specification of "lty", "lwd" and "col" line parameters as arguments to
The V1.6.0 internal C code for do_axis was changed to facilitate this
and therefore the axis call in V.1.6.0 barplot() as above now results in
no line being drawn, since the "lty = 0" (blank) argument in not
overridden in the internal C code.
Hence the (perhaps unintended) change in the default behavior in
barplot() in V.1.6.0.
It took me a while to track this down and finally isolated it to the
axis() function change in 1.6.0.
I am also copying this reply to r-devel, more as an FYI, since my guess
is that other functions, either R standard functions or community based
functions, may have their default behavior altered as well.
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