我在pycharm里运行的,然后最后面两行就出错!

#一行显示多张图像和标签
def show_fashion_mnist(images,labels):
d2l.use_svg_display()
_,figs = d2l.plt.subplot(1,len(images),figsize=(12,12))
for f,img,lbl in zip(figs,images,labels):
f.imshow(img.reshape((28,28)).asnumpy())
f.set_title(lbl)
f.axes.get_xaxis().set_visible(False)
f.axes.get_yaxis().set_visible(False)

# x,y = mnist_train[0:9]
# show_fashion_mnist(x,get_fashion_mnist_labels(y))

 File "D:\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 1084, in subplot
a = fig.add_subplot(*args, **kwargs)

File “D:\Anaconda3\lib\site-packages\matplotlib\figure.py”, line 1367, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File “D:\Anaconda3\lib\site-packages\matplotlib\axes_subplots.py”, line 65, in init
raise ValueError(‘Illegal argument(s) to subplot: %s’ % (args,))
ValueError: Illegal argument(s) to subplot: (1, 9)

请问各位大神这个是为什么?

subplots

开头你可以加上import matplotlib.pyplot as plt,最后要加上一句plt.show()就可以啦