Skip to content

[Bug]: Linewidths in scatter unexpectedly scale when using "o" shape #29703

Closed as not planned
@shadiekay

Description

@shadiekay

Bug summary

When setting the linewidths parameter in scatter there is some type of scaling applied which produces unexpected results. The inner diameter of the linewidth/contour is not fitted to the outer diameter of the marker, when saving the plot as a png. When viewing the plot as html the linewidth is attached to the marker but scales oddly.

Code for reproduction

import matplotlib.pyplot as plt
pos = {
        1: [-0.64773329, -0.61381879],
        2: [-0.08689388, -0.64267512],
        3: [0.11388331, -0.15139483],
        4: [0.13119441, 0.40788873],
        5: [0.48954945, 1.0],
        6: [0.7, 1.0]

    }

xy = np.asarray([pos[v] for v in pos])
node_collection = plt.scatter(
        xy[:, 0],
        xy[:, 1],
        s=12,
        c="red",
        marker="o",
        linewidths=45,
        edgecolors="green",
    )

plt.show()

Actual outcome

I unfortunately cannot attach the html file but I have attached the relevant screenshots.

HTML print page:
myplot_html.pdf

HTML screenshot:
Image

HTML screenshot zoomed:
Image

HTML screenshot zoomed more:
Image

Expected outcome

I expect the linewidths to remain fixed and be next to the marker when printing the plot.

Additional information

There is scaling functionality but I don't think the linewidth calculates the inner diameter based on the diameter of the marker, causing it to display with a completely different diameter.

Operating system

OS/X

Matplotlib Version

3.9.4

Matplotlib Backend

module://backend_interagg

Python version

3.10.8

Jupyter version

No response

Installation

pip

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