[R] histogram scaling

Chris Friedl cfriedalek at gmail.com
Wed Aug 19 08:59:04 CEST 2009

Hey, Rajesh

I bit light on detail here. Being a mind reader is not an R-help
prerequisite. However since I have been working on histograms today and
you've just posted a question using ggplot, let me guess that its ggplot you
are refering to. Then here is an example, which you can find in my post a
few posts previous to yours. I've added scale_ commands to restrict the x
and y scales. Actually in this example both histograms get plotted on the
same y-scale automatically so that command can be removed.

Check out the ggplot on line reference http://had.co.nz/ggplot2/ and book


x <- data.frame(value=rnorm(5000, mean=0), case="A")
y <- data.frame(value=rnorm(5000, mean=3), case="B")
xy <- rbind(x, y)
ggplot(xy, aes(x=value, fill=case, group=case)) + geom_histogram(alpha=0.5,
binwidth=0.1, position="identity") + scale_x_continuous(limits=c(-2,3)) +

rajesh j wrote:
> Hi,
> I'm drawing two histograms in the same plot.However, my point of
> comparison
> is the difference in their x coordinates.But my problem is one histogram
> is
> much taller than the other.How can I get them both to the same height?
> -- 
> Rajesh.J
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

View this message in context: http://www.nabble.com/histogram-scaling-tp25038602p25038798.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list