Skip to content

scatter(..., marker='') raises on drawing with mpl3.3.1 #18254

Closed

Description

@MaozGelbart

Bug report

Bug summary

plt.scatter() raises upon drawing when called with marker='' (no errors with 3.3.0).
This change of behavior broke seaborn.

Code for reproduction

import matplotlib.pyplot as plt
plt.scatter([], [], marker='')  # fails also with plt.scatter([1,2,3], [1,2,3], marker='')
plt.show()

Actual outcome

Traceback (most recent call last):
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/backends/backend_macosx.py", line 61, in _draw
    self.figure.draw(renderer)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/figure.py", line 1863, in draw
    mimage._draw_list_compositing_images(
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
    return func(*inner_args, **inner_kwargs)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/axes/_base.py", line 2748, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
    a.draw(renderer)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/collections.py", line 931, in draw
    Collection.draw(self, renderer)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/collections.py", line 385, in draw
    extents = paths[0].get_extents(combined_transform)
  File "/Users/maoz/.local/lib/python3.8/site-packages/matplotlib/path.py", line 603, in get_extents
    return Bbox([xys.min(axis=0), xys.max(axis=0)])
  File "/Users/maoz/miniconda/envs/seaborn_devenv/lib/python3.8/site-packages/numpy/core/_methods.py", line 43, in _amin
    return umr_minimum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation minimum which has no identity

Expected outcome

Not to fail.

Matplotlib version

  • Operating system: MacOS
  • Matplotlib version: 3.3.1
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX (also reproduces with %inline)
  • Python version: 3.8.3
  • Jupyter version (if applicable):
  • Other libraries: numpy 1.19.1

matplotlib installed through pip

Activity

  1. jklymak commented on Aug 14, 2020

    @jklymak
    Member

    Hmmm, maybe a backport went bad, because this works fine on master...

  2. added this to the v3.3.2 milestone on Aug 14, 2020
  3. jklymak commented on Aug 14, 2020

    @jklymak
    Member

    Seems to bisect to 662dc23 which looks right...

  4. jklymak commented on Aug 14, 2020

    @jklymak
    Member

    ... but 662dc23 is exactly the same as master, so something else changed under it....

  5. jklymak commented on Aug 14, 2020

    @jklymak
    Member

    Its something in _path.cleanup_path that didn't get back ported at the same time. @brunobeltran I think this maybe has to do with your path work? This bug is still present, so far as I can tell, on v3.3.x, but its not a bug on master... The only other hint I have is that in path.py/get_extents the value of self.vertices is empty on v3.3.x, but not empty on master. Either we need to back port whatever 662dc23 was depending on, or we need to revert 662dc23 on the back port branch.

  6. QuLogic commented on Aug 14, 2020

    @QuLogic
    Member

    Simple patch, if we don't figure out any more specific cleanup fixes:

    diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py
    index 5088596a8..e1daf35ee 100644
    --- a/lib/matplotlib/path.py
    +++ b/lib/matplotlib/path.py
    @@ -600,7 +600,10 @@ class Path:
                     # as can the ends of the curve
                     xys.append(curve([0, *dzeros, 1]))
                 xys = np.concatenate(xys)
    -        return Bbox([xys.min(axis=0), xys.max(axis=0)])
    +        if len(xys):
    +            return Bbox([xys.min(axis=0), xys.max(axis=0)])
    +        else:
    +            return Bbox.null()
     
         def intersects_path(self, other, filled=True):
             """
  7. QuLogic commented on Aug 14, 2020

    @QuLogic
    Member

    This works in master because we only reverted #17543 for 3.3.x. On master, there are no facecolors because 'none' is an unfilled marker, so the single path optimization is not checked, and then Path.get_extents is not called. The bug is still there, it's just not triggered.

  8. added a commit that references this issue on Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions