Search code examples
rhistogramnormal-distribution

How to lower height of normal distribution curve


I would like to shorten the height of my normal dist curve so that the full curve can be seen on the graph.

histCvferr <- hist(cvf_ref_err, breaks = 10, density = 60,
             col = "lightgray", xlab = "Residuals", main = "") 
xfit <- seq(min(cvf_ref_err), max(cvf_ref_err), length = 40) 
yfit <- dnorm(xfit, mean = mean(cvf_ref_err), sd = sd(cvf_ref_err)) 
yfit <- yfit * diff(h$mids[1:2]) * length(cvf_ref_err) 
lines(xfit, yfit, col = "black", lwd = 2)

As you can see the top part of the curve cuts off

And also how can I change the bins so that they are black outlines with no fill?


Solution

  • Try passing a new argument "ylim" in the hist() function and change the range of y. Try passing the following argument in the hist() function. I hope this might help you.

    ylim = c(0, 70)