简体   繁体   中英

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'.

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 []. Curly brackets in python are typically used to denote dictionaries. Also, remove the brackets from lijst1 and lijst2 in your call to the plot function.

The following code produces a plot for me in 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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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