Pycharm不会绘图

问题描述 投票:0回答:1

我有这段代码,应该为我绘制一个带有数字的图表,但是它不起作用。而且我没有任何错误

import numpy
import matplotlib.pyplot

# %matplotlib inline
all_values = data_list[0].split(',')
image_array = numpy.asfarray(all_values[1:]).reshape((28, 28))
matplotlib.pyplot.imshow(image_array, cmap='Greys', interpolation='None')
plt.show(image_array, cmap='Greys', interpolation='None')  
scaled_input = (numpy.asfarray(all_values[1:]) / 255.0 * 0.99) + 0.1
print (scaled_input)

谢谢您的回答!

python matplotlib pycharm
1个回答
0
投票

您的代码甚至不应运行:

  • [all_values = data_list[0].split(',')应该给NameError: data_list undefined
  • [plt.show应该给NameError: plt undefined
  • [plt.show(image_array, cmap='Greys', interpolation='None')应该给TypeError: got an unexpected keyword argument 'cmap'

我的猜测是您的代码根本没有运行...在PyCharm中,您应该能够右键单击脚本,然后单击run script或其他内容

© www.soinside.com 2019 - 2024. All rights reserved.