You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Resolution of Collection with unfilled markers edgecolors depends on whether colors are passed in constructor or later #26904
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.
The basic problem is that scatter has a special behavior for unfilled markers: they are treated as if they had only a face, not an edge, even though in fact it is the other way around. From the docstring (and #17543):
For non-filled markers, *edgecolors* is ignored. Instead, the color
is determined like with 'face', i.e. from *c*, *colors*, or
*facecolors*.
But scatter then returns a generic PathCollection, initialized with the marker's path, that doesn't know about this behavior, so it has no way to maintain it when color attributes are subsequently changed.
I think the solution might be to make a MarkerCollection subclass of PathCollection. Some of the color manipulation logic would then be moved from the Axes.scatter() method to the new class.
Alternatively, just accept and document the current behavioral inconsistency.
Activity
QuLogic commentedon Sep 25, 2023
I assume this has something to do with property resolution that @efiring refactored some time ago.
efiring commentedon Oct 6, 2023
The basic problem is that
scatterhas a special behavior for unfilled markers: they are treated as if they had only a face, not an edge, even though in fact it is the other way around. From the docstring (and #17543):But
scatterthen returns a genericPathCollection, initialized with the marker's path, that doesn't know about this behavior, so it has no way to maintain it when color attributes are subsequently changed.I think the solution might be to make a
MarkerCollectionsubclass ofPathCollection. Some of the color manipulation logic would then be moved from theAxes.scatter()method to the new class.Alternatively, just accept and document the current behavioral inconsistency.