Skip to content
Back to formatted view

Raw Message

Message-ID: <43380B34.20824.18B6494@localhost>
Date: 2005-09-26T12:52:36Z
From: PIKAL Petr
Subject: hist(x, ...)  with  normal distribution  curve
In-Reply-To: <43369942.6070604@usa.com>

Hi

answered hundered times.

> Dear R people: 
> 
> I would like to superimpose a normal curve on a histogram. 
x<-rnorm(150) 
h<-hist(x,breaks=15) 
xhist<-c(min(h$breaks),h$breaks) 
yhist<-c(0,h$density,0) 
xfit<-seq(min(x),max(x),length=40) 
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x)) 
plot(xhist,yhist,type="s",ylim=c(0,max(yhist,yfit))) 
lines(xfit,yfit) 


Bill 

above is e.g. Bill Simpson's answer from 2001. Found from R-site 
search  ***histogram density normal***.

HTH
Petr


On 25 Sep 2005 at 14:34, Knut Krueger wrote:

> .
> I am looking for a histogram or box plot with the adding  normal
> distribution  curve I think that must be possible, but I am not able
> to find out how to do.
> 
> 
> 
> Regards Knut
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz