2013-11-28 54 views
0

我得到相同的縮放和相同的字幕。這不是我想要的。我怎樣才能重置字幕和縮放?更改多個地塊的subtile

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) 
+0

這裏有格式化的東西很奇怪......你能解決它嗎?看看http://stackoverflow.com/editing-help – YXD

+0

我試過,但我無法修復它:( – Rotail

+0

是'fig1','fig2'和'fig3'三個不同的數字?我有這種感覺你正在同一個圖的同一軸上疊加'imshow'。 –

回答

1

每塊之後,必須有一個plt.close()以避免過度繪圖。

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) 

附註:如果圖中只有一個軸,則可以使用軸標題。