小编ola*_*ola的帖子

绘制多个seaborn displot

我正在尝试创建按列分组的数据框的 distplot

data_plot = creditcard_df.copy()
amount = data_plot['Amount']
data_plot.drop(labels=['Amount'], axis=1, inplace = True)
data_plot.insert(0, 'Amount', amount)

# Plot the distributions of the features
columns = data_plot.iloc[:,0:30].columns
plt.figure(figsize=(12,30*4))
grids = gridspec.GridSpec(30, 1)
for grid, index in enumerate(data_plot[columns]):
    ax = plt.subplot(grids[grid])
    sns.distplot(data_plot[index][data_plot.Class == 1], hist=False, kde_kws={"shade": True}, bins=20)
    sns.distplot(data_plot[index][data_plot.Class == 0], hist=False, kde_kws={"shade": True}, bins=20)
    ax.set_xlabel("")
    ax.set_title("Distribution of Column: "  + str(index))
    plt.show()
Run Code Online (Sandbox Code Playgroud)

阴谋 我尝试对 y 轴使用对数刻度,更改 gridspec 和 Figsize;但所有这些只会让发行版变得一团糟。有没有办法让图统一?

python matplotlib pandas seaborn displot

3
推荐指数
1
解决办法
9524
查看次数

标签 统计

displot ×1

matplotlib ×1

pandas ×1

python ×1

seaborn ×1