Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 使用子图作为循环的迷你散射矩阵_Python 3.x_Seaborn - Fatal编程技术网

Python 3.x 使用子图作为循环的迷你散射矩阵

Python 3.x 使用子图作为循环的迷你散射矩阵,python-3.x,seaborn,Python 3.x,Seaborn,我有一个25列的数据集,想检查散点图。我第一次看它是带着微笑的 Seabornscatterplot()但这太混乱了,而且有太多的图表无法解释所有这些。 因此,我想在所有列上迭代一个列。 我创建了这个简单的循环: for col in ds_num.columns: plt.figure() sns.scatterplot(x='initial_term',y=col,hue='logo_renewal',data=ds_num) plt.show() 这是可行的,但它

我有一个25列的数据集,想检查散点图。我第一次看它是带着微笑的 Seaborn
scatterplot()
但这太混乱了,而且有太多的图表无法解释所有这些。 因此,我想在所有列上迭代一个列。 我创建了这个简单的循环:

for col in ds_num.columns:
    plt.figure()
    sns.scatterplot(x='initial_term',y=col,hue='logo_renewal',data=ds_num)
    plt.show()
这是可行的,但它给了它一个柱状的形状。我希望它在每一行中绘制一些,所以我尝试了以下方法:

for idx, col in enumerate(ds_num.columns):
    fig = plt.figure(figsize=(20,16))
    ax[idx+1] = fig.add_subplot(5,5,idx+1)
    sns.scatterplot(x='initial_term',y=col,hue='logo_renewal',data=ds_num,ax=ax[idx])
    plt.show()
但现在我得到了TypeError:“AxeSubPlot”对象不支持项分配


有什么建议吗?谢谢

在子地块的帮助下找到了答案:

fig, axs = plt.subplots(5,5,figsize=(20,20))
cols = ds_num.columns
for ax, col in zip(axs.flatten(),cols):
    sns.scatterplot(x='initial_term',y=col,hue='logo_renewal',data=ds_num,ax=ax,legend=False)
    plt.tight_layout()
注意,我删除了图例,因为它占用了太多的空间,这当然不是强制性的