matplotlib / matplotlib/matplotlib
[Bug]: Resolution of Collection with unfilled markers edgecolors depends on whether colors are passed in constructor or later
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 23.2k
- Forks
- 8.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 66
Description
### 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
```python
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided reproduction with matplotlib 3.8 and inspect the scatter entry point plus the collection's set_color, set_facecolor, and get_edgecolor behavior. Compare both construction paths and add or update coverage so unfilled-marker collections produce the same edgecolor result after set_facecolor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100