在PyPlot子图中的Seaborn中设置图形大小

时间:2019-10-18 04:39:32

标签: python matplotlib 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 Scatter Plot中以分类着色显示散点图?

1 个答案:

答案 0 :(得分:0)

这有效-

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=