I'm trying to plot two probability density functions on one figure(so that they overlap).
import matplotlib.pyplot as plt
import numpy
import seaborn as sns
from sklearn.preprocessing import MinMaxScaler
import numpy as np
import pandas as pd
data = [0,0,1,2,2,2,2,1,2,3,0,5,4,5,4,6,2,2,5,4,6,3,2,5,4,3,7,-1,0]
scaler = MinMaxScaler()
df = pd.DataFrame(data, columns=['Numbers'])
X = numpy.asarray(data)
X=X.reshape(-1,1)
standardized_data = scaler.fit_transform(X)
normal_data = np.random.normal(loc=0.0, scale=1.0, size=len(df))
sns.displot(normal_data, kind='kde')
sns.displot(standardized_data, kind='kde')
plt.show()
CodePudding user response:
sns.displot(
{"normal": normal_data, "standardized": standardized_data.squeeze()},
kind='kde'
)