Python:希望在同一个风中显示多个图形

2024-10-03 00:23:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我很难让我的四个绘图显示在同一个窗口中,而不显示它们a)覆盖或b)出现错误:

[AttributeError: 'AxesSubplot' object has no attribute 'plt']

下面是我试图修复的代码部分:

if(debug_on):      
    fig, axs = plt.subplots(2,2,sharex=True, sharey=True)
    img_1 = remap.pedf(upsampled_smoothed_mag1)
    im_1 = axs[0,0].plt.imshow(img_1,aspect='auto',origin='lower',extent=[0,img_1.shape[1],0,img_1.shape[0]])                            
    fig.colorbar(im_1),
    plt.title('Unsampled smoothed - 1')
    plt.show()
    plt.pause(0.05)

    img_2 = remap.pedf(upsampled_smoothed_mag2)
    im_2 = axs[0,1].plt.imshow(img_2,aspect='auto',origin='lower',extent=[0,img_2.shape[1],0,img_2.shape[0]])
    fig.colorbar(im_2)
    plt.title('Unsampled smoothed - 2')
    plt.show()
    plt.pause(0.05)

    img_3 = remap.pedf(upsampled_smoothed_mag1_2)
    im_3 = axs[1,0].plt.imshow(img_3,aspect='auto',origin='lower',extent=[0,img_3.shape[1],0,img_3.shape[0]])                            
    fig.colorbar(im_3)
    plt.title('Unsampled smoothed - 1 (2.0)')
    plt.show()
    plt.pause(0.05)

    img_4 = remap.pedf(upsampled_smoothed_mag2_2)
    im_4 = axs[1,1].plt.imshow(img_4,aspect='auto',origin='lower',extent=[0,img_4.shape[1],0,img_4.shape[0]])
    fig.colorbar(im_4)
    plt.title('Unsampled smoothed - 2 (2.0)')
    plt.show()
    plt.pause(0.05)

提前感谢您的帮助!另外,我是个新手


Tags: imgautofigpltoriginlowershapeimshow