Using distplot to plot a histogram
sns.distplot(a, color="red", label="100% Equities")
and running this under Seaborn version 0.11 or greater produces a warning that distplot will be deprecated and to use displot instead.
Using displot as a direct replacement (simply changing the function name from distplot to displot) does not produce the same histogram.
What is the replacement code?
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.
11.2 (August 2021)
For simple plots where x is a vector of data, displot(x) and histplot(x) are drop-in replacements for distplot(x) . Both functions also allow you to add a KDE curve by setting kde=True . As an enhancement, the new functions will plot a KDE over a histogram that shows counts, rather than requiring density normalization.
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.
Use
histplot
instead of distplot
kde=True, stat="density", linewidth=0
So:
sns.histplot(a, color="red", label="100% Equities", kde=True, stat="density", linewidth=0)
replaces
sns.distplot(a, color="red", label="100% Equities")
Example of Code for Hisplot to show the frequency of first state and zero state of the machine at each point:
feature2_ok = df.loc[df["target"] == 1]
feature2_ng = df.loc[df["target"] == 0]
fig, ax = plt.subplots(figsize=(20, 6))
sns.histplot(feature2_ok["feature_2"], color="orange", label="100% Equities", kde=True, linewidth=0)
sns.histplot(feature2_ng["feature_2"], label="100% Equities", kde=True, linewidth=0)
ax.set(xlim=(-100, 700),
xticks=[-100, -50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700])
plt.legend(["Frist State", "Zero State"])
plt.title('Machine Performance Feature 2')
plt.ylabel('Frequency')
plt.grid()
plt.show()
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