[R] two histograms in the same graph
Duncan Murdoch
murdoch at stats.uwo.ca
Thu Jan 24 16:11:45 CET 2008
On 1/24/2008 9:43 AM, Juan Pablo Fededa wrote:
> Dear Contributors:
>
> I have two vectors x and z, and I want to display the histograms of both
> vectors in the same graph, x in red bars, z in blue bars.
> If you have any clue on how to do that, I will be very glad to hear it!!!!!!
It's hard to design a graph like this that looks good, but it's easy to
draw using add=TRUE:
x <- rnorm(1000)
y <- rnorm(1000, mean=1)
breaks <- pretty(range(c(x,y)), 20)
hist(x, breaks=breaks, col='red', main="Hist of x and y")
hist(y, breaks=breaks, add=TRUE, border='blue')
Duncan Murdoch
More information about the R-help
mailing list