[R] Newbie: Barchart Gray with White Grid?

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Nov 16 15:44:29 CET 2003

On Sun, 16 Nov 2003, Tom Hopper wrote:

> I'm just getting in to R, been reading manuals (thanks to all who 
> provided pointers to good docs!), and messing with different commands. 
> I'd appreciate a little help with this exploration, and I hope that my 
> question is relatively easy to answer (probably, there's a simple way 
> to do what I'm working toward).
> R's statistical functions are coming along easily enough, but graphics 
> seem to be a little tougher for me, probably because I'm used to 
> working in SigmaPlot. As an exercise, I tried to create a gray bar 
> chart with white grid overlay, like the one on page 128 of Tufte's 
> "Visual Display of Quantitative Information." I  figure this would 
> cover a lot of the basic techniques that I'll need for "real" work. I 
> got as far as having a gray bar chart (I was working within hist(), 
> mostly) with white borders, white (on white background) axes, white 
> grid *under* the bars, and both x- and y-axis labels (both the numeric 
> or categorical label, and the axis titles...I don't quite remember the 
> correct terms in R).
> I wasn't able to find a way to display only the gridlines parallel to 
> the x-axis, or to overlay that grid on top of the bars, or to turn off 
> the numeric labels on the x-axis without touching the y-axis, or to 
> show the x-axis as a gray line without showing the y-axis.

?grid (and the hint in the details).

?par and look at xaxt and yaxt.  Then use axis() to add the axes you want.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list