Skip to content

[Bug]: ax.scatter([], [], clip_on=False, label=...) renders a ghost marker at the origin/corner when combined with specific styles/limits #32219

Description

@daemonenstall

Bug summary

When passing an empty dataset to ax.scatter() with clip_on=False and a label, calling ax.legend() causes a marker artifact to render incorrectly at the bottom-left edge of the plot. Toggling clip_on=True makes the artifact disappear.

Code for reproduction

import matplotlib.pyplot as plt
import scienceplots

plt.style.use("science")

fig, ax = plt.subplots()

ax.set_xlim(1, 180)
ax.set_ylim(9.90, 10.15)

# Empty scatter with clip_on=False and a legend label
ax.scatter(
    [], [], 
    color="red", 
    s=50, 
    facecolors="none", 
    edgecolors="red", 
    linewidths=1,
    label="Outlier", 
    clip_on=False
)

ax.legend()
plt.show()

Actual outcome

clip_on=False => artifact in the lower left corner
Image

Expected outcome

clip_on=True => no artifact in the lower left corner

Image

Additional information

Happens also when exporting as pgf and embedding into a Latex document.

Operating system

Arch

Matplotlib Version

3.10.9

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.13.14

Jupyter version

7.6.2

Installation

pixi

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions