有没有办法在countplot
中堆叠条形图,使每个条形图包含两种颜色。
到目前为止我的代码如下:
fig, axes = plt.subplots(4, 4, figsize=(15,13), sharex=True)
axes = axes.flatten()
object_bol = df.dtypes == 'object'
for ax, catplot in zip(axes, df.dtypes[object_bol].index):
sns.countplot(y=catplot, data=df, ax=ax, hue = "Attrition")
plt.tight_layout()
plt.show()
下面是我当前的可视化,以及我希望实现的堆叠图。
发布于 2019-02-22 03:53:04
从seaborn.countplot
通过You can pass keyword arguments连接到plt.bar
。
因此,您可以使用bottom
参数。例如(使用plt.bar
):
x = np.arange(0,11,1)
y = x**2
plt.bar(x, y)
plt.bar(x, y, bottom=y)
plt.xlabel('x')
plt.ylabel('y')
提供:
https://stackoverflow.com/questions/54814824
复制相似问题