graph - How to plot exponential function on barplot R? -
so have barplot in y axis log (frequencies). eyeing it, appears bars decrease exponentially, know sure. want plot exponential on same graph. thus, if bars fall below exponential, know bars decrease either exponentially or faster exponential, , if bars lie on top of exponential, know dont decrease exponentially. how plot exponential on bar graph?
here graph if helps:
if you're trying fit density of exponential function, should plot density histogram (not frequency). see this question on how plot distributions in r.
this how it.
x.gen <- rexp(1000, rate = 3) hist(x.gen, prob = true) library(mass) x.est <- fitdistr(x.gen, "exponential")$estimate curve(dexp(x, rate = x.est), add = true, col = "red", lwd = 2)
Comments
Post a Comment