Suggestion for improvement of the plot.histogram() function (Was: FW: [Rd] Name spaces and behavior of overloaded functions?)

Henrik Bengtsson hb@maths.lth.se
Thu Jan 30 09:26:05 2003


On request from Martin Maechler I suggest the following improvement to
base::plot.histogram(), which makes it possible to plot several
histograms next to each other in the same plot by making them sharing
space. You can set the width and the offset the bars should have.
Example:

x1 <- rnorm(1000,  0.4, 0.8)
x2 <- rnorm(1000,  0.0, 1.0)
x3 <- rnorm(1000, -1.0, 1.0)
hist(x1, width=0.33, offset=0.00, col="blue", xlim=c(-4,4),
main="Histogram of x1, x2 & x3", xlab="x1 - blue, x2 - red, x3 - green")
hist(x2, width=0.33, offset=0.33, col="red", add=TRUE) hist(x3,
width=0.33, offset=0.66, col="green", add=TRUE)

More info and code can be found (for a couple of weeks) at 

  http://www.maths.lth.se/help/R/plot.histogram/

Best wishes

Henrik Bengtsson