我怎样才能有两行多列的子图

时间:2018-12-27 20:22:33

标签: python subplot

下面的代码生成带有几行图像的一行图像。 我想在当前行的下方或上方添加另一行,其中包含test数组中的另一系列图像,这与predict数组相似。我为子图尝试了多个数字,例如2而不是1,但它只是给出错误信息或不起作用。如果我将1替换为2,则会在第四行显示错误AttributeError: 'numpy.ndarray' object has no attribute 'matshow',这似乎无关紧要!

您能指导我该怎么办吗?

fig, ax = plt.subplots(1, len(predict), figsize=(10, 5))
fig.suptitle('Output Data with bias term {0}'.format(b))
for i in range(len(predict)):
    ax[i].matshow(predict[i].reshape((n_units, n_units)), cmap='gray')
    ax[i].set_xticks([])
    ax[i].set_yticks([])
plt.show('{0:02d}'.format(b))

enter image description here

0 个答案:

没有答案