简体   繁体   English

如何从2个列表中制作图形?

[英]How can I make a graphics out of 2 lists?

I have two lists, and from those 2 lists I want to make a graphic.Here I have a piece of code that I tried but it gave me the error 我有两个列表,并且要从这两个列表中绘制图形,这里有一段我​​尝试过的代码,但它给了我错误

'TypeError: float() argument must be a string or a number'. “ TypeError:float()参数必须是字符串或数字”。

What can I do to solve this? 我该怎么解决?

import matplotlib.pyplot as plt

lijst1={1,2,3}
lijst2={1,2,3}

plt.plot([lijst1],[lijst2], 'ro')
plt.axis ([1,10,0,10])

plt.show()

Try replacing the curly brackets from lijst1 and lijst2 with standard brackets []. 尝试用标准括号[]替换lijst1和lijst2中的大括号。 Curly brackets in python are typically used to denote dictionaries. python中的花括号通常用于表示字典。 Also, remove the brackets from lijst1 and lijst2 in your call to the plot function. 同样,在调用plot函数时,从lijst1和lijst2除去括号。

The following code produces a plot for me in python 3.5 以下代码在python 3.5中为我生成了一个图

import matplotlib.pyplot as plt

lijst1=[1,2,3]
lijst2=[1,2,3]

plt.plot(lijst1,lijst2, 'ro')
plt.axis ([1,10,0,10])

plt.show()

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

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