Just a quick question: I'm trying to add a density line to my histogram
lines(x,dbeta(x,6,3))
I've previously defined:
x = runif(100000,0,1)
However rather than 'joining the dots' of the beta distribution, it 'fills in with colour' the whole are under it. So I'm basically left with a coloured in beta distribution overlayed on my histogram.
I've tried changing the line types, but this doesn't seem to help. How can I just make it into a single-lined overlayed plot?
you are plotting pairs of random numbers with it's corresponding density... if you simply want to overlay the line, don't use runif()
, but seq()
:
x <- seq(from=0, to=1, length.out=10000)
lines(x, dbeta(x, 6,3))