With matplotlib 3.4.0, scatter plot with colormap and legend gives TypeError: object of type 'NoneType' has no len().
Traceback (most recent call last):
File ".../matplotlib/backends/backend_qt5.py", line 475, in _draw_idle
self.draw()
File ".../matplotlib/backends/backend_agg.py", line 406, in draw
self.figure.draw(self.renderer)
File ".../matplotlib/artist.py", line 74, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
File ".../matplotlib/artist.py", line 51, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File ".../matplotlib/figure.py", line 2734, in draw
mimage._draw_list_compositing_images(
File ".../matplotlib/image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File ".../matplotlib/artist.py", line 51, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File ".../matplotlib/_api/deprecation.py", line 431, in wrapper
return func(*inner_args, **inner_kwargs)
File ".../matplotlib/axes/_base.py", line 2925, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File ".../matplotlib/image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File ".../matplotlib/artist.py", line 51, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File ".../matplotlib/legend.py", line 614, in draw
self._legend_box.draw(renderer)
File ".../matplotlib/offsetbox.py", line 368, in draw
c.draw(renderer)
File ".../matplotlib/offsetbox.py", line 368, in draw
c.draw(renderer)
File ".../matplotlib/offsetbox.py", line 368, in draw
c.draw(renderer)
[Previous line repeated 1 more time]
File ".../matplotlib/offsetbox.py", line 694, in draw
c.draw(renderer)
File ".../matplotlib/artist.py", line 51, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File ".../matplotlib/collections.py", line 1009, in draw
super().draw(renderer)
File ".../matplotlib/artist.py", line 51, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File ".../matplotlib/collections.py", line 380, in draw
len(facecolors) == 1 and len(edgecolors) == 1 and
TypeError: object of type 'NoneType' has no len()
Bug report
Bug summary
With matplotlib 3.4.0, scatter plot with colormap and legend gives TypeError: object of type 'NoneType' has no len().
Code for reproduction
Actual outcome
Traceback (most recent call last): File ".../matplotlib/backends/backend_qt5.py", line 475, in _draw_idle self.draw() File ".../matplotlib/backends/backend_agg.py", line 406, in draw self.figure.draw(self.renderer) File ".../matplotlib/artist.py", line 74, in draw_wrapper result = draw(artist, renderer, *args, **kwargs) File ".../matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File ".../matplotlib/figure.py", line 2734, in draw mimage._draw_list_compositing_images( File ".../matplotlib/image.py", line 132, in _draw_list_compositing_images a.draw(renderer) File ".../matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File ".../matplotlib/_api/deprecation.py", line 431, in wrapper return func(*inner_args, **inner_kwargs) File ".../matplotlib/axes/_base.py", line 2925, in draw mimage._draw_list_compositing_images(renderer, self, artists) File ".../matplotlib/image.py", line 132, in _draw_list_compositing_images a.draw(renderer) File ".../matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File ".../matplotlib/legend.py", line 614, in draw self._legend_box.draw(renderer) File ".../matplotlib/offsetbox.py", line 368, in draw c.draw(renderer) File ".../matplotlib/offsetbox.py", line 368, in draw c.draw(renderer) File ".../matplotlib/offsetbox.py", line 368, in draw c.draw(renderer) [Previous line repeated 1 more time] File ".../matplotlib/offsetbox.py", line 694, in draw c.draw(renderer) File ".../matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File ".../matplotlib/collections.py", line 1009, in draw super().draw(renderer) File ".../matplotlib/artist.py", line 51, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File ".../matplotlib/collections.py", line 380, in draw len(facecolors) == 1 and len(edgecolors) == 1 and TypeError: object of type 'NoneType' has no len()Expected outcome
With matplotlib 3.3.4, I get this (no warning or error):
Matplotlib version