【问题标题】:Changing the subtile in multiple plots更改多个绘图中的子图块
【发布时间】:2013-11-28 12:54:39
【问题描述】:

我得到相同的缩放比例和相同的字幕。这不是我想要的。如何重置字幕和缩放?

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)

【问题讨论】:

  • 这里的格式有点奇怪......你能解决它吗?看看stackoverflow.com/editing-help
  • 我试过但我无法修复它:(
  • fig1fig2fig3 三个不同的数字?我觉得您在同一图形的同一轴上过度绘制了 imshow
  • 完全正确。如何避免过度写入?
  • stackoverflow.com/a/14261698/380231 你的问题根源在于脚本中状态机接口的使用。

标签: python matplotlib plot subtitle


【解决方案1】:

在每个块之后必须有一个plt.close() 以避免过度绘图。

【讨论】:

    【解决方案2】:
    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)
    

    附带说明,如果图中只有一个轴,则可以只使用轴标题。

    【讨论】:

      猜你喜欢
      • 2020-09-16
      • 2019-12-02
      • 1970-01-01
      • 2021-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-28
      相关资源
      最近更新 更多