Extend density plot line (along 0)

If I write

using StatsPlots

then I get:

The plot would be nicer if the blue line extended all the way to the maximum/minimum x values (along 0). Is there an option for this?

If I understand you correctly you want density to pad its estimate with zeros up to some maximum value which is determined by a different call to density? I don’t think there’s an option for this and I’m not even sure how that would work in practice (what if you plot a third density? would the first two plots have to be extended accordingly?) so you need to do it manually by adding something like

julia> plot!(1.1:0.01:1.6, zeros(length(1.1:0.01:1.6)), color = 1, label = "")

Instead of inventing new data, you could force the lines to land on the x-axis at y=0.
In this case, just using the argument widen=false would do the trick.

Not sure about the widen=false, I tried it but didn’t really seem to work (I increased lw to make things clearer)

using StatsPlots

(I tried putting the widen=false in various places, and =true, in case I misunderstood something, but with no success)

@nilshg I don’t need it to predict the length of the padding according to the previous call, I agree that this would be weird. But an option like

using StatsPlots

which then continues the line to the given interval (even if just 0) is what I would be looking for (I’d could then manually set it to whatever I would require). If there’s nothing like that though, trying to stitch things together like you suggest, with separate lines, seem like it might produce an acceptable result.

To me it looks good. But some people see a hat, while others a boa and an elephant.