简体   繁体   English

不能 plot 图表与 matplotlib

[英]Can't plot a chart with matplotlib

I have this code, and it's supposed to plot me a chart with a number, but it won't work.我有这个代码,它应该是 plot 我一个带有数字的图表,但它不起作用。 And I don't get any error而且我没有收到任何错误

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)

Thank you for your answers!谢谢您的回答!

Your code should not even run:您的代码甚至不应该运行:

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

My guess is that your code did not run at all... In PyCharm, you should be able to right click on your script and click on run script or something我的猜测是您的代码根本没有运行...在 PyCharm 中,您应该能够右键单击您的脚本并单击run script或其他东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM