[R] Newbie: Barchart Gray with White Grid?

Adaikalavan RAMASAMY ramasamya at gis.a-star.edu.sg
Sun Nov 16 15:42:35 CET 2003

The examples in help(hist) and help(barplot) uses the argument col='gray' etc to set the color of the barplots/histograms. As for grids, the following may help
tN <- table(Ni <- rpois(100, lambda=5))
r <- barplot(tN, col="gray", xaxt="n")          # alternatively  hist(Ni, col="gray", freq=T)
abline( h=seq(0,max(tN), by=5), col="white" )

To turn off the numeric labels, use xaxt="n" option in the plot() command. You can try to set the background using the bg="blue". This and more options are documented in par().
-----Original Message----- 
From: r-help-bounces at stat.math.ethz.ch on behalf of Tom Hopper 
Sent: Sun 11/16/2003 9:26 PM 
To: r-help at stat.math.ethz.ch 
Subject: [R] Newbie: Barchart Gray with White Grid?

	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.
	Has anyone done this? How?
	Thank you,
	R-help at stat.math.ethz.ch mailing list

More information about the R-help mailing list