停止Seaborn在彼此之上绘制多个图形

停止Seaborn在彼此之上绘制多个图形,第1张

停止Seaborn在彼此之上绘制多个图形

为此,您必须开始一个新的图形。假设您有,有多种方法可以做到这一点

matplotlib
。也摆脱它,
get_figure()
您可以
plt.savefig()
从那里使用。

方法1

采用

plt.clf()

import seaborn as snsimport matplotlib.pyplot as pltiris = sns.load_dataset('iris')length_plot = sns.barplot(x='sepal_length', y='species', data=iris)plt.savefig('ex1.pdf')plt.clf()width_plot = sns.barplot(x='sepal_width', y='species', data=iris)plt.savefig('ex2.pdf')

方法2

plt.figure()
每个人之前致电

plt.figure()length_plot = sns.barplot(x='sepal_length', y='species', data=iris)plt.savefig('ex1.pdf')plt.figure()width_plot = sns.barplot(x='sepal_width', y='species', data=iris)plt.savefig('ex2.pdf')


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5651055.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存