1
import numpy as np
sns.distplot( np.random.normal(0,1,100), hist=True, kde=True, 
             bins=int(80/5), color = 'darkblue', 
             hist_kws={'edgecolor':'black'},
             kde_kws={'linewidth': 2})

plt.title('Gaussian noise 1')
plt.savefig('GaussianNoise1.png')


sns.distplot( np.random.normal(0,2,200), hist=True, kde=True, 
             bins=int(80/5), color = 'darkblue', 
             hist_kws={'edgecolor':'black'},
             kde_kws={'linewidth': 2})

plt.title('Gaussian noise 2')
plt.savefig('GaussianNoise2.png')

I would like to save both figure say (Gaussian noise 1 and Gaussian noise 2) into 1 single file.

With current code, both files are being saved into 2 different file as I am using two diffrent file name. If I use same file name, then old figure is being overwritten by the new figure.

I would like to keep both old and new figure together in same file as I do multiple simulations.

Further, I would like to generalize the results for multiple figures getting saved in the same file.

  • Thank you for sharing the links @JodyKlymak, @ D.L. But they don't answer my question. I would like to save multiples figures on the same file dynamically (as I run multiples simulation, I would like to keep the results a.k.a Figure) – Pinky Kapoor Feb 26 '23 at 17:17
  • 1
    Png is not a multi page format so it’s not clear what you are trying to do. There are PDFPages – Jody Klymak Feb 26 '23 at 18:10

0 Answers0