Issue
I have a collection of measured tree diameters and am trying to plot a histogram with a kernel density estimation superimposed on top in python. The seaborn module lets me do this quite simply but I can find no way of specifying that the kde should be zero for negative numbers (since trees can't have negative tree diameters).
what I've got at present is this:
seaborn.distplot(C77_diam, rug=True, hist=True, kde=True)
I've looked at seaborn.kdeplot which is the function that distplot calls but can't find anything useful. Does anyone know if this can be done with seaborn, and if not if it can be done with matplotlib more generally?
I only started using seaborn because i couldn't figure out how to overlay a kde pyplot.plot() with a pyplot.hist().
Solution
There's no way to force the density estimate to zero with that function, but you can always set the axis limits such that the left side of the plot starts at 0.
seaborn.distplot(C77_diam, rug=True, hist=True, kde=True).set(xlim=(0, max_diam))
Answered By - mwaskom
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.