python - 如何在 pandas 中保存 lmplot

标签 python pandas matplotlib visualization figures

对于regplot,这是有效的:

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 绘图,我收到错误:

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)

关于python - 如何在 pandas 中保存 lmplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51152776/

相关文章:

Python——sympysolve()返回另一个方程而不是值

Matplotlib,使用 latex 的一致字体

python - 如何将 python 类型注释添加到 flask 全局上下文 g?

python - 如何使用 json_normalize 规范化嵌套 json

python - 没有xcom的任务之间的 Airflow 通信

python - 为每一行计算子数据帧行的最有效方法?

python - 多列上的 Pandas cumsum + cumcount

python - 如何识别 matplotlib 中的图形线

python - 如何获取 Pandas 中某些特定日期之前和之后的日期时间?

python - 无法将性别数据更改为二进制值