Skip to content

[Bug]: Resolution of Collection with unfilled markers edgecolors depends on whether colors are passed in constructor or later #26904

Open
@anntzer

Description

@anntzer

Bug summary

In the example below, I construct two collections of unfilled markers via scatter(..., marker="x"). In one case I set the marker colors in the constructor, in the other case I set it immediately after via an explicit setter call.
I then set the collection's facecolor (it doesn't matter here for unfilled markers, but one can imagine this is generic code where the marker used actually comes from elsewhere and I just have marker=user_specified and here the user just happened to be "x".
I then probe the collection's edgecolor (which is how the cross will actually be drawn). In the first case, the edgecolor actually switched to blue, i.e. it followed the facecolor. In the second case it stays (red, green), i.e. it followed the set_color call and ignored the later set_facecolor.

Code for reproduction

from pylab import *

coll = plt.scatter([0, 1], [0, 1], marker="x",
                   color=["r", "g"])
coll.set_facecolor("b")
print(coll.get_edgecolor())

coll = plt.scatter([0, 1], [0, 1], marker="x")
coll.set_color(["r", "g"])
coll.set_facecolor("b")
print(coll.get_edgecolor())

Actual outcome

[[0. 0. 1. 1.]]
[[1. 0. 0. 1. ]
[0. 0.5 0. 1. ]]

Expected outcome

Same output for both collections.

Additional information

No response

Operating system

macos

Matplotlib Version

3.8

Matplotlib Backend

agg

Python version

3.11

Jupyter version

ENOSUCHLIB

Installation

git checkout

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