小编Bil*_*mer的帖子

Seaborn中位数模式线仅显示在最后一张图中

我试图显示meanmedianmode线两个图,但他们只是在最后图可见:

#Cut the window in 2 parts
f, (ax_box, ax_hist) = plt.subplots(2, sharex=True, gridspec_kw={"height_ratios": (0.2, 1)})
#plt.figure(figsize=(10,7));
mean=df[' rating'].mean()
median=df[' rating'].median()
mode=df[' rating'].mode().get_values()[0]
plt.axvline(mean, color='r', linestyle='--')
plt.axvline(median, color='g', linestyle='-')
plt.axvline(mode, color='b', linestyle='-')
plt.legend({'Mean':mean,'Median':median,'Mode':mode})

sns.boxplot(df[" rating"], ax=ax_box)
sns.distplot(df[" rating"], ax=ax_hist)

ax_box.set(xlabel='')
Run Code Online (Sandbox Code Playgroud)

python matplotlib seaborn

4
推荐指数
2
解决办法
3671
查看次数

标签 统计

matplotlib ×1

python ×1

seaborn ×1