如何在pandas中进行列式绘图?

问题描述 投票:-1回答:1

我做了一个DataFrame,如下

enter image description here

我想把它绘制成像这样的countplot。

enter image description here

其中色调是我的数据框架的一列。

pandas matplotlib data-visualization seaborn
1个回答
0
投票

不太清楚你的表是什么格式,如果你使用下面这样的pd.crosstab,你可以很容易地调用plot.bar()来给出你想要的图。

import seaborn as sns
tab = pd.crosstab(np.random.choice(["very useful","somewhat useful","not useful"],1000),
                  np.random.choice(["test","kaggle"],1000))
tab.plot.barh()

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.