【绘图】【Python】Python数据分析matplotlib设置多个子图的间距以及设置总图的标题

版权声明:本文为博主原创文章,未经博主允许不得转载。保留追究法律责任,转载联系博主。交流欢迎加QQ群463339221。 https://blog.csdn.net/m0_37362454/article/details/82848499
# 设定画图板尺寸
plt.figure(figsize=(12,16))
# 建立一个循环,输出图片
for i,data in enumerate(xtest[:100]):
#     设定子图,将每个子图输出到对应的位置
    plt.subplot(10,10,i+1)
#     输出图片,取出来的数据是必须处理好再输出的,此例为8*8
    plt.imshow(data.reshape(8,8))
#     测试的标题和真实的标题打印出来
    plt.title('C:'+str(y_[i])+'\nT:'+str(ytrue[:100][i]),size=20)
#     关掉x y轴的刻度
    plt.axis('off')
#     调整每隔子图之间的距离
    plt.tight_layout()

fig.tight_layout()#调整整体空白 plt.subplots_adjust(wspace =0, hspace =0)#调整子图间距

matplotlib subplots 设置总图的标题 :fig.suptitle(dname,fontsize=16,x=0.53,y=1.05,)

猜你喜欢

转载自blog.csdn.net/m0_37362454/article/details/82848499
今日推荐