Hello, This may seem like a simple problem, but it's frustrating me immensely. I'm trying to overlay a normal curve (dnorm) on top of a histogram using the code below. This works find when the type = "density", but the person for whom I'm making the plot wants the y axis in percent of total rather than density. When I change type to "percent", I get the histogram scale I'm after, but the dnorm plot is greatly reduced. How could I scale the density plot to the percent of total axis. Alternatively, perhaps there is a way to add density to a secondary y axis?
Thanks in advance for your help. Jimdare plot<-histogram(~rdf[,j]|Year,nint=20, data=rdf,main = i,strip = my.strip,xlab = j, type = "percent",layout=c(2,1), panel=function(x, ...) { panel.histogram(x, ...) panel.mathdensity(dmath=dnorm, col="black", # Add na.rm = TRUE to mean() and sd() args=list(mean=mean(x, na.rm = TRUE), sd=sd(x, na.rm = TRUE)), ...) }) -- View this message in context: http://r.789695.n4.nabble.com/Lattice-Histogram-with-Normal-Curve-Y-axis-as-percentages-tp4690000.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.