[R] barplot(): X-Axis Labels

Martin Maechler maechler at stat.math.ethz.ch
Tue Oct 15 09:35:11 CEST 2002


>>>>> "Marc" == Marc Schwartz <mschwartz at medanalytics.com>
>>>>>     on Mon, 14 Oct 2002 11:51:30 -0500 writes:

    >> -----Original Message-----
    >> Martin Hoyle wrote:
    >> 
    >> Try using las=2 in the barplot command;
    >> 
    >> barplot(response variable means,names=levels(explanatory
    >> variable),las=2)
    >> 
    >> The text is then at 90 degrees,
    >> 
    >> >>> Jess Balint <jbalinc at insight.rr.com> 10/13/02 10:47PM >>>
    >> 
    >> Hello all. I have a simple barplot with sixteen different segments.
    >> When I plot my data, only five or six of the labels are showing in the
    >> x-axis. How do go get them all to show? Can I set them at a 45.degree
    >> angle? Thank you.
    >> 
    >> Jess

    Marc> In addition to Martin's suggestion, you might wish to use meaningful
    Marc> abbreviations to shorten the labels.

    Marc> You can also use par("cex.axis") to make the font a bit smaller.  You'll
    Marc> need to draw the x and y axis separately, lest both fonts be small.
    Marc> Example:

    Marc> mp <- barplot(1:16, axes = FALSE, axisnames = FALSE)
    Marc> axis(2)
    Marc> axis(1, at = mp, labels = 1:16, cex.axis = 0.5)

    Marc> ....
    Marc> ....   {more nice explanations and examples}
    Marc> ....

Just a remark on the example above (and the ones not cited
here), particularly since I've seen other people do the same:

If it's just one axis annotation that you want to "fiddle" with
and the other drawn regularly, it's slightly ``nicer'' to use
{with the above}

  mp <- barplot(1:16, xaxt = "n", axisnames = FALSE)
  ##                  ~~~~~~~~~~
  axis(1, at = mp, labels = 1:16, cex.axis = 0.5)

instead of `` axes = FALSE '' and the extra ``axis(2)'' command.

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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