简体   繁体   English

pyplot总是绘制直线

[英]pyplot plotting straight line always

I have this code to plot some data in python using matplotlib:我有这个代码到 plot python 使用 matplotlib 中的一些数据:

import matplotlib.pyplot as plt
x=[1,2,5]
y=[2,4,1]
plt.plot(x,y)
plt.show()

This this plots perfectly, here is the result:这完美地绘制,这是结果:

pyplot 示例工作

In my another code, I have this value:在我的另一个代码中,我有这个值:

x = [0 1 2 3 4 5 6 7 8 9]

y = ['7065' '2604' '2003' '1939' '1746' '1578' '1472' '1414' '1320' '1288']

Now, what I get is this:现在,我得到的是:

pyplot工作乱码

Bar graph, is also same, here:条形图,也是一样的,这里:

条形图错误

It always gives me a straight line, why is that?它总是给我一条直线,这是为什么呢?

Values are visible in Python Shell值在Python Shell中可见

I wrote this:我写了这个:

y = list(map(int, y))

And the str list became int list. str列表变成了int列表。

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

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