Re: [R] Superimposing Line over Histogram in Density Plot

2008-06-16 Thread Carl Witthoft
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

Re: [R] Superimposing Line over Histogram in Density Plot

2008-06-16 Thread David Arnold
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

Re: [R] Superimposing Line over Histogram in Density Plot

2008-06-16 Thread Dimitris Rizopoulos
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