我创建了一个简单的函数来帮助我可视化数据集。我在下面提供玩具数据和代码以及输出。我的问题是我找不到控制子图大小和总体图(网格)的方法。我试图传递诸如figsize之类的参数或直接嵌入plt.figure(figsize =(12,8)),但这些尝试均失败。
玩具数据:
'{"Principal":{"333":800,"7":800,"61":1000,"275":1000,"51":1000,"154":1000,"264":800,"306":1000,"73":800,"265":1000,"25":1000,"114":1000,"202":1000,"340":1000,"182":1000,"200":1000,"339":1000,"82":1000,"267":1000,"132":800},"Gender":{"333":"male","7":"male","61":"male","275":"male","51":"male","154":"male","264":"male","306":"male","73":"female","265":"male","25":"male","114":"male","202":"male","340":"male","182":"male","200":"male","339":"female","82":"male","267":"male","132":"male"},"loan_status":{"333":"COLLECTION","7":"PAIDOFF","61":"PAIDOFF","275":"COLLECTION","51":"PAIDOFF","154":"PAIDOFF","264":"COLLECTION","306":"COLLECTION","73":"PAIDOFF","265":"COLLECTION","25":"PAIDOFF","114":"PAIDOFF","202":"PAIDOFF","340":"COLLECTION","182":"PAIDOFF","200":"PAIDOFF","339":"COLLECTION","82":"PAIDOFF","267":"COLLECTION","132":"PAIDOFF"}}'
代码:
def continuous_by_categorical_by_Class(df, Feature_binned, Feature_Categorical, Target):
import seaborn as sns
bins=np.linspace(df[Feature_binned].min(), df[Feature_binned].max(), 10)
g = sns.FacetGrid(df, col=Feature_Categorical, hue= Target, palette="Set1", \
col_wrap= len(df[Feature_Categorical].unique()))
g.map(plt.hist, Feature_binned, bins=bins, ec="k")
g.axes[-1].legend()
plt.show()
您的建议将不胜感激。