Skip to content

Expire Artist.set() property reordering #20077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/api/next_api_changes/behavior/20077-TH.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
``Artist.set`` applies artist properties in the order in which they are given
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The change only affects the interaction between the *color*, *edgecolor*,
*facecolor*, and, for `.Collection`\s, *alpha* properties: the *color* property
now needs to be passed first in order not to override the other properties.
This is consistent with e.g. `.Artist.update`, which did not reorder the
properties passed to it.
24 changes: 0 additions & 24 deletions lib/matplotlib/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,30 +1152,6 @@ def properties(self):
def set(self, **kwargs):
"""A property batch setter. Pass *kwargs* to set properties."""
kwargs = cbook.normalize_kwargs(kwargs, self)
move_color_to_start = False
if "color" in kwargs:
keys = [*kwargs]
i_color = keys.index("color")
props = ["edgecolor", "facecolor"]
if any(tp.__module__ == "matplotlib.collections"
and tp.__name__ == "Collection"
for tp in type(self).__mro__):
props.append("alpha")
for other in props:
if other not in keys:
continue
i_other = keys.index(other)
if i_other < i_color:
move_color_to_start = True
_api.warn_deprecated(
"3.3", message=f"You have passed the {other!r} kwarg "
"before the 'color' kwarg. Artist.set() currently "
"reorders the properties to apply 'color' first, but "
"this is deprecated since %(since)s and will be "
"removed %(removal)s; please pass 'color' first "
"instead.")
if move_color_to_start:
kwargs = {"color": kwargs.pop("color"), **kwargs}
return self.update(kwargs)

def findobj(self, match=None, include_self=True):
Expand Down