0

I get the same scaling and same subtitles. This is not what I want. How can I reset the subtitle and scaling?

plt.imshow(grid1, extent=(x1.min(), x1.max(), y1.min(), y1.max()), origin='lower',  
           aspect='auto', interpolation='nearest', cmap=cm.gist_rainbow)      
fig1 = plt.gcf()
fig1.suptitle('Effectualness_etta of %s and %s' % (waveform1, waveform2))
plt.colorbar()
plt.draw()
fig1.savefig('/home/saeed/pycbc/test/plots/TDFD_Effectualness_etta_%s_%s.pdf'
             % (waveform1, waveform2), dpi=100)

plt.imshow(grid3, extent=(x3.min(), x3.max(), y3.min(), y3.max()), origin='lower',
           aspect='auto', interpolation='nearest', cmap=cm.gist_rainbow)
fig3 = plt.gcf()
fig3.suptitle('Effectualness_mo_M_chirp of %s and %s' % (waveform1, waveform2))
fig3.savefig('/home/saeed/pycbc/test/plots/TDFD_Real_Effectualness_mo_%s_%s.pdf'
              % (waveform1, waveform2), dpi=100)

plt.imshow(grid2, extent=(x2.min(), x2.max(), y2.min(), y2.max()), origin='lower', 
           aspect='auto', interpolation='nearest', cmap=cm.gist_rainbow)
fig2 = plt.gcf()
fig2.suptitle('Effectualness_M_chirp of %s and %s' % (waveform1, waveform2))
fig2.savefig('/home/saeed/pycbc/test/plots/TDFD_Effectualness_Mchirp_%s_%s.pdf'
             % (waveform1, waveform2), dpi=100)
Francesco Montesano
  • 8,485
  • 2
  • 40
  • 64
Rotail
  • 1,025
  • 4
  • 19
  • 40

2 Answers2

1

After each block there must be a plt.close() to avoid over plotting.

Rotail
  • 1,025
  • 4
  • 19
  • 40
0
for (grid, x, y, subtitle_str, save_path_str) in zip([grid1, grid2, grid3],
                                                     [x1, x2, x3], [y1, y2, y3], 
                                                     list_of_titles, list_of_paths)):    
    fig, ax = plt.subplots()
    im = ax.imshow(grid, extent=(x.min(), x.max(), y.min(), y.max()), origin='lower',  
               aspect='auto', interpolation='nearest', cmap=cm.gist_rainbow)      
    fig.suptitle(suptitle_str)
    # or
    # ax.set_title(suptitle_str)
    fig.colorbar(im)
    fig.savefig(save_path_str, dpi=100)

As a side note, if you only have one axes in the figure, you can just use the axes title.

tacaswell
  • 84,579
  • 22
  • 210
  • 199