参考:https://blog.csdn.net/gatieme/article/details/61416645
matplotlib
中提供的 subplot
可以很好的解决这个问题
subplot(numRows, numCols, plotNum)
图表的整个绘图区域被分成
numRows
行和numCols
列然后按照从左到右,从上到下的顺序对每个子区域进行编号,左上的子区域的编号为1
plotNum
参数指定创建的Axes
对象所在的区域具体代码:
plt.figure('generative_image_compression')#标题名字 plt.subplot(121)#构建1行2列的,先画第1个图 plt.imshow(test_images)#显示第1个图
plt.subplot(122)#构建1行2列的,先画第2个图 plt.imshow(recon_img)#显示第2个图 plt.axis('off')#关闭坐标轴 plt.show()#画图!
在显示过程中出现的问题:
1.图像格式类型不正确,必须是np.array
2.图像维度不正确,需要用到reshape:
recon_img=recon_img.reshape(64,64,3)
#print('test_images_type', type(test_images))##显示数据类型 #print('test_image_shape:', test_images.shape)##显示数据维度