I have an array of data, called data1, that contains values from 0 to more than a thousand. I only want to have a histogram and a KDE of those values from 0 to 10. Hence I wrote:
sns.distplot(data1, kde=True, hist=True, hist_kws={"range": [0,10]})
plt.show()
What I get however is a histogram of all values (well into 2000s).
This function has been deprecated and will be removed in seaborn v0. 14.0. It has been replaced by histplot() and displot() , two functions with a modern API and many more capabilities.
distplot() The seaborn. distplot() function accepts the data variable as an argument and returns the plot with the density distribution. Example 1: import numpy as np import seaborn as sn import matplotlib.
For simple plots where x is a vector of data, displot(x) and histplot(x) are drop-in replacements for distplot(x) .
You could just filter your data and call displot
over the filtered data:
filtered = data1[(data1 >= 0) & (data1 < 10)]
sns.distplot(filtered, kde=True, hist=True, hist_kws={"range": [0,10]})
plt.show()
Assuming data1
is a numpy array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With