【发布时间】:2021-03-10 15:00:41
【问题描述】:
是否可以从 seaborn 中获取直方图并添加正态分布?
假设我有类似这样的散点图和直方图from the documentation.
import seaborn as sns
penguins = sns.load_dataset("penguins")
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm");
plt.savefig('deletethis.png', bbox_inches='tight')
我可以像下图那样在侧面叠加分布吗?
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
x = np.random.normal(size=100000)
# Plot histogram in one-dimension
plt.hist(x,bins=80,density=True)
xvals = np.arange(-4,4,0.01)
plt.plot(xvals, norm.pdf(xvals),label='$N(0,1)$')
plt.legend();
【问题讨论】:
标签: python matplotlib plot seaborn histogram