为此,您必须开始一个新的图形。假设您有,有多种方法可以做到这一点
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')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)