如何在 pandas 中保存 lmplot
How to save lmplot in pandas
对于 reg plot,这是有效的:
sns_reg_plot = sns.regplot(x="X", y="y", data=df)
sns_reg_fig = sns_reg_plot.get_figure()
sns_reg_fig.savefig(path)
但是对于 lm plot 我得到一个错误:
sns_lm_plot = sns.lmplot(x="X", y="y", hue="hue", data=df)
..
sns_lm_fig = sns_lm_plot.get_figure()
AttributeError: 'FacetGrid' object has no attribute 'get_figure'
只需删除 .get_figure 行
sns_im_plot = sns.lmplot(x="X", y="y",hue="hue" data=df)
sns_im_plot.savefig(path)
对于 reg plot,这是有效的:
sns_reg_plot = sns.regplot(x="X", y="y", data=df)
sns_reg_fig = sns_reg_plot.get_figure()
sns_reg_fig.savefig(path)
但是对于 lm plot 我得到一个错误:
sns_lm_plot = sns.lmplot(x="X", y="y", hue="hue", data=df)
..
sns_lm_fig = sns_lm_plot.get_figure()
AttributeError: 'FacetGrid' object has no attribute 'get_figure'
只需删除 .get_figure 行
sns_im_plot = sns.lmplot(x="X", y="y",hue="hue" data=df)
sns_im_plot.savefig(path)