Issue
I use
sns.distplot
to plot a univariate distribution of observations. Still, I need not only the chart, but also the data points. How do I get the data points from matplotlib Axes (returned by distplot)?
Solution
You can use the matplotlib.patches API. For instance, to get the first line:
sns.distplot(x).get_lines()[0].get_data()
This returns two numpy arrays containing the x and y values for the line.
For the bars, information is stored in:
sns.distplot(x).patches
You can access the bar's height via the function patches.get_height()
:
[h.get_height() for h in sns.distplot(x).patches]
Answered By - Nils Gudat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.