Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

float() argument must be a string or a number, not 'zip'

There is no problem when I run in python 2.7 but I am getting error when I run in python 3.

Is there something that I need to change in this code.

import matplotlib as mpl
poly = mpl.path.Path(zip(listx,listy))

error that I am getting is

TypeError: float() argument must be a string or a number, not 'zip'
like image 365
bikuser Avatar asked Oct 27 '16 10:10

bikuser


1 Answers

This is because in python2 zip() returns a list of tuples, which mpl.path.Path() happily accepts. In python3, zip() returns an iterator, which you must consume. You should be able to do something like:

>>> poly = mpl.path.Path(list(zip(listx, listy)))
like image 75
msvalkon Avatar answered Nov 06 '22 17:11

msvalkon