Stop seaborn plotting multiple figures on top of one another

前端 未结 3 713
太阳男子
太阳男子 2020-12-23 20:21

I\'m starting to learn a bit of python (been using R) for data analysis. I\'m trying to create two plots using seaborn, but it keeps saving the second on top of

3条回答
  •  太阳男子
    2020-12-23 20:52

    Create specific figures and plot onto them:

    import seaborn as sns
    iris = sns.load_dataset('iris')
    
    length_fig, length_ax = plt.subplots()
    sns.barplot(x='sepal_length', y='species', data=iris, ax=length_ax)
    length_fig.savefig('ex1.pdf')
    
    width_fig, width_ax = plt.subplots()
    sns.barplot(x='sepal_width', y='species', data=iris, ax=width_ax)
    width_fig.savefig('ex2.pdf')
    

提交回复
热议问题