[R] Normalized Y-axis for Histogram Density Plot

Greg Snow Greg.Snow at imail.org
Wed Sep 2 18:55:02 CEST 2009


Your data ranges from 0.67 to 1.21, just to simplify things let's assume the that the histogram will go from the pretty numbers of 0.65 to 1.25 for a total width of 0.6.  Now consider the simplest histogram consisting of 1 single bar going from 0.65 to 1.25 (very uninteresting histogram, but good for this example).  The probability=T argument means that the total area of the histogram (1 rectangle for this simple case) must be equal to 1.

If you can explain to us how to create a rectangle with width = 0.6 and area =1 and a height that is between 0 and 1, then we will be happy to explain the rest of your question (though I expect that trying to answer the above will answer your question for you).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Gundala Viswanath
> Sent: Tuesday, September 01, 2009 10:17 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Normalized Y-axis for Histogram Density Plot
> 
> I have the following data which I tried to draw
> the probability density plot.
> 
> Here is the code I have:
> 
> x <- read.table("mydat.txt");
> d <- rep(x$V2,times=x$V3);
> hist(d,probability=T, xlab="FlowSignal");
> 
> But why the y-axis range from 0 to 6,
> instead of 0 to 1?  What's the correct way to plot it?
> 
> 
> #id  flowsignal frequency
> 1       0.67    1
> 1       0.70    1
> 1       0.75    1
> 1       0.78    2
> 1       0.79    1
> 1       0.83    1
> 1       0.84    3
> 1       0.85    3
> 1       0.86    1
> 1       0.88    1
> 1       0.89    1
> 1       0.91    1
> 1       0.93    1
> 1       0.94    1
> 1       0.96    2
> 1       0.98    4
> 1       0.99    2
> 1       1.00    2
> 1       1.01    1
> 1       1.02    5
> 1       1.04    3
> 1       1.05    5
> 1       1.06    5
> 1       1.07    4
> 1       1.08    7
> 1       1.09    6
> 1       1.10    2
> 1       1.11    2
> 1       1.14    1
> 1       1.15    1
> 1       1.17    1
> 1       1.20    1
> 1       1.21    1
> #end of data
> 
> 
> Regard,
> G.V.
> 
> ______________________________________________
> 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.




More information about the R-help mailing list