EDIT: The issue is most likely about the version. The levels
argument takes an integer argument in version 3.0.0, while this issue has occurred while using version 2.2.2.
UPDATE: The issue didn't occur after installing the version >=3.0.0.
I'm trying to make a contour plot in Python using the matplotlib.pyplot.contourf()
function, and it works perfectly like this:
plt.contourf(x, y, z)
but when I try to specify an integer for the levels argument, like this:
plt.contourf(x, y, z, levels=100)
it always returns the error: TypeError: len() of unsized object
In the documentation, it says that the argument levels
can be either int
or array_like
so I don't know why it would even call the len()
function
Any ideas why this happens and any suggestion on how to fix it?