You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling plt.legend(...) with arguments of type <class 'itertools.chain'> no longer works, and raises TypeError: object of type 'itertools.chain' has no len(). This used to work - some update to the source code seems to have caused this bug.
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\jonny\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\pyplot.py", line 3628, in legend
return gca().legend(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jonny\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\axes_axes.py", line 337, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jonny\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\legend.py", line 462, in init
if len(handles) < 2:
^^^^^^^^^^^^
TypeError: object of type 'itertools.chain' has no len()
Expected outcome
For the legend to be correctly applied, as previously.
Additional information
No response
Operating system
No response
Matplotlib Version
3.10.3
Matplotlib Backend
tkagg
Python version
No response
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered:
We used to explicitly cast to list right before the length check, but that was removed in #24811 on the grounds it was then redundant. However we have since removed the loop that created the list in #28874.
The original decision to cast to list goes way back.
Uh oh!
There was an error while loading. Please reload this page.
Bug summary
Calling
plt.legend(...)
with arguments of type<class 'itertools.chain'>
no longer works, and raisesTypeError: object of type 'itertools.chain' has no len()
. This used to work - some update to the source code seems to have caused this bug.Code for reproduction
Actual outcome
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\jonny\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\pyplot.py", line 3628, in legend
return gca().legend(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jonny\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\axes_axes.py", line 337, in legend
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jonny\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\matplotlib\legend.py", line 462, in init
if len(handles) < 2:
^^^^^^^^^^^^
TypeError: object of type 'itertools.chain' has no len()
Expected outcome
For the legend to be correctly applied, as previously.
Additional information
No response
Operating system
No response
Matplotlib Version
3.10.3
Matplotlib Backend
tkagg
Python version
No response
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: