I do it a bit differently:
Once you've got myhist, you can plot a line on the existing histogram
plot with something like:
smoo<-spline(myhist$breaks[1:length(myhist$breaks)-1],myhist$counts)
lines(smoo$x,smoo$y,col='green')
You'll have to muck a bit with scale factors to make the spline curve
Look here:
http://msenux.redwoods.edu/mathdept/R/CentralLimit.php
D.
On Jun 15, 2008, at 11:25 PM, Gundala Viswanath wrote:
Hi,
Currently I have a density plot generated with this
snippet.
Is there a way I can add a line curve on top of it?
I mean in one figure
__BEGIN__
myhist <- hist
try something like this:
x <- rnorm(200)
hist(x, col = "blue", freq = FALSE)
lines(density(x), col = "red", lwd = 2)
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgiu
3 matches
Mail list logo