首页 > 解决方案 > 在 PyPlot 子图中设置 Seaborn 中的图形大小

问题描述

我有一段代码可以在一个图像中绘制多个散点图 -

columns_for_clusters = set(column_types_and_names['object']) - set(ignore_columns_in_model)
columns_for_clusters = list(columns_for_clusters)
fig,ax1 = plt.subplots(math.ceil((len(column_types_and_names["int64"]) - 2)/3),3)
plt.figure(figsize=(16, 6))

x = 0
for index in range(0,len(column_types_and_names["int64"])):
  if(column_types_and_names["int64"][index] != 'SalePrice' and column_types_and_names["int64"][index] != 'Id'):
    #train.plot(kind="scatter", x="SalePrice", y=column_types_and_names["int64"][index], ax=ax1[int(x / 3)][x % 3],figsize = (30,40), s = 1)
    g =sns.scatterplot(x="SalePrice", y=column_types_and_names["int64"][index],
          hue=columns_for_clusters[0],
          data=train, ax = ax1[int(x / 3)][x % 3]);
    x = x + 1
plt.show()

地块的大小非常小。我该如何解决?

我必须绘制 12*3 的情节该情节在 Pandas Plot 中有效。有没有办法在 Pandas 散点图中显示带有分类颜色的散点图?

标签: pythonmatplotlibseaborn

解决方案


这有效 -

columns_for_clusters = set(column_types_and_names['object']) - set(ignore_columns_in_model)
columns_for_clusters = list(columns_for_clusters)
fig,ax1 = plt.subplots(math.ceil((len(column_types_and_names["int64"]) - 2)/3),3)
plt.figure(figsize=(30, 40))

x = 0
for index in range(0,len(column_types_and_names["int64"])):
  if(column_types_and_names["int64"][index] != 'SalePrice' and column_types_and_names["int64"][index] != 'Id'):
    #train.plot(kind="scatter", x="SalePrice", y=column_types_and_names["int64"][index], ax=ax1[int(x / 3)][x % 3],figsize = (30,40), s = 1)
    sns.scatterplot(x="SalePrice", y=column_types_and_names["int64"][index],
      hue=columns_for_clusters[0],
      data=train, ax = ax1[int(x / 3)][x % 3]);
    x = x + 1
plt.show()

删除g=


推荐阅读