Skip to content
Advertisement

Get data points from Seaborn distplot

I use

JavaScript

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)?

Advertisement

Answer

You can use the matplotlib.patches API. For instance, to get the first line:

JavaScript

This returns two numpy arrays containing the x and y values for the line.

For the bars, information is stored in:

JavaScript

You can access the bar’s height via the function patches.get_height():

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement