Anton Lambrecht
Anton Lambrecht

Reputation: 13

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()

Upvotes: 0

Views: 40

Answers (1)

Austin
Austin

Reputation: 80

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()

Upvotes: 1

Related Questions