[R] histogram scaling

2009-08-19 Thread rajesh j
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@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.


Re: [R] histogram scaling

2009-08-19 Thread Chris Friedl

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
http://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf

hth


require(ggplot2)
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)) +
scale_y_continuous(limits=c(0,250))




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@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.

__
R-help@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.