matplotlib库画子图的方法总结

subplot画子图

for index,n in enumerate(imgName):
    plt.subplot(params["batch_size"],params["batch_size"],index*3+1,title="Input" if index==0 else "")
    plt.imshow(x[index].transpose(0,1).transpose(1,2).contiguous())
    plt.axis("off") # 去掉 x y轴
    plt.subplot(params["batch_size"],params["batch_size"],index*3+2,title="GT)
    plt.imshow(y[index],cmap="gray")
    plt.axis("off")
    plt.subplot(params["batch_size"],params["batch_size"],index*3+3,title="Mask")
    plt.imshow(mask[index],cmap="gray")
    plt.axis("off")
    # plt.subplots_adjust(left=0.027,
    #                     bottom=0,
    #                     right=0.99,
    #                     top=0.93,
    #                     wspace=0.005,
    #                     hspace=0.045)
    fig.tight_layout()

subplots画子图

fig,axes=plt.subplots(params["batch_size"],params["batch_size"])
for index,n in enumerate(imgName):
    axes[index,0].imshow(x[index].transpose(0,1).transpose(1,2).contiguous())
    axes[index, 0].axis("off")
    axes[index,1].imshow(y[index],cmap="gray")
    axes[index, 1].axis("off")
    axes[index,2].imshow(mask[index],cmap="gray")
    axes[index, 2].axis("off")
    axes[0,0].set_title("Input")
    axes[0,1].set_title("GT")
    axes[0,2].set_title("Mask")
    plt.subplots_adjust(left=0.027,
                            bottom=0,
                            right=0.99,
                            top=0.93,
                            wspace=0.005,
                            hspace=0.045)
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值