如何显示所有列的单独博平图?

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

当我试图显示所有列的boxplots时,我使用了这个命令。

df_num.boxplot(rot=90)

enter image description here

但正如你所看到的,这些框是如此之小,因为它们的范围是不同的,不应该共享同一个Y轴。我可以做一些像下面的东西,但在boxplots中?谢谢!当我尝试显示boxplots时,我发现它们的范围很小,而且不应该共享同一个y轴。enter image description here

python dataframe matplotlib seaborn boxplot
1个回答
0
投票

你可以这样做(例子中只包括2个列,但你显然可以添加更多)。

fig, ax = plt.subplots(figsize=(12,6), ncols=2)
df_num["backers_count"].plot.box(ax=ax[0])
df_num["converted_pledged_amount"].plot.box(ax=ax[1]);

...或者用Seaborn。

fig, ax = plt.subplots(figsize=(12,6), ncols=2)
sns.boxplot(data=df_num, y="backers_count", ax=ax[0])
sns.boxplot(data=df_num, y="converted_pledged_amount", ax=ax[1]);

如果你想把它们显示在一个三行三列的网格中,那么你可以改变它们的位置 ncols=2 咬合 nrows=3, ncols=3,然后代替 ax=ax[0], ax=ax[1] 等你写 ax=ax[0,0], ax=ax[0,1]

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