【发布时间】:2018-07-12 10:49:50
【问题描述】:
Seaborn 是一个很棒的软件包,countplot 是一个很棒的功能,具有令人愉悦的视觉效果。
有一个关于如何access-to-bin-counts-in-seaborn-distplot 的问题。例如。当前答案使用numpy.histogram。
问题是,在我们获得分布并根据需要对其进行处理之后,如何使用更改后的分布来创建与计数图等效的图,例如
tl;dr:这是我的问题(示例取自 seaborn.countplot):
复制粘贴代码:
%matplotlib inline
import seaborn as sns
sns.set(style="darkgrid")
titanic = sns.load_dataset("titanic")
ax = sns.countplot(x="class", data=titanic)
import numpy as np
titanic_classes = titanic['class'].map({s:i for i,s in enumerate(titanic['class'].dtype.categories)}).values
titanic_counts = np.bincount(titanic_classes)
#now add ship2 counts
ship2_counts = [8, 9, 25]
total_counts = titanic_counts + ship2_counts
total_counts
【问题讨论】:
标签: python matplotlib histogram seaborn