How to save a Seaborn plot into a file

后端 未结 10 1062
庸人自扰
庸人自扰 2020-12-07 08:43

I tried the following code (test_seaborn.py):

import matplotlib
matplotlib.use(\'Agg\')
import matplotlib.pyplot as plt
matplotlib.style.use(\'g         


        
10条回答
  •  天命终不由人
    2020-12-07 09:12

    Fewer lines for 2019 searchers:

    import matplotlib.pyplot as plt
    import seaborn as sns
    
    df = sns.load_dataset('iris')
    sns_plot = sns.pairplot(df, hue='species', height=2.5)
    plt.savefig('output.png')
    

    UPDATE NOTE: size was changed to height.

提交回复
热议问题