Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ def draw(self, renderer):
return
renderer.open_group(self.__class__.__name__, self.get_gid())

# Bail if the collection does not have any offsets (e.g., an empty scatter plot)
if len(self.get_offsets()) == 0:
renderer.close_group(self.__class__.__name__)
self.stale = False
return
Comment thread
ayshih marked this conversation as resolved.

self.update_scalarmappable()

transform, offset_trf, offsets, paths = self._prepare_points()
Expand Down
18 changes: 18 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3217,6 +3217,24 @@ def test_scatter_singular_plural_arguments(self):
facecolors=["#ffffff", "#000000", "#f0f0f0"],
facecolor="#ffffff")

@pytest.mark.parametrize('edgecolor, facecolor, linestyle',
[('red', 'blue', 'solid'),
('red', 'blue', 'dashed'),
('red', 'none', 'solid'),
('none', 'blue', 'solid')])
@check_figures_equal()
def test_empty_scatter(self, fig_test, fig_ref, edgecolor, facecolor, linestyle):
# Verify that a spurious marker is not plotted in the bottom-left corner
# https://github.com/matplotlib/matplotlib/issues/32219
ax_test = fig_test.subplots()
ax_test.scatter([], [], ec=edgecolor, fc=facecolor, ls=linestyle, clip_on=False)
ax_test.set_xlim(0, 1)
ax_test.set_ylim(0, 1)

ax_ref = fig_ref.subplots()
ax_ref.set_xlim(0, 1)
ax_ref.set_ylim(0, 1)


def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
return (c, edgecolors, kwargs, xsize)
Expand Down
Loading