Skip to content

Cleanup QuiverKey init and deprecate some attributes.#31170

Merged
ksunden merged 1 commit intomatplotlib:mainfrom
anntzer:qki
Mar 6, 2026
Merged

Cleanup QuiverKey init and deprecate some attributes.#31170
ksunden merged 1 commit intomatplotlib:mainfrom
anntzer:qki

Conversation

@anntzer
Copy link
Copy Markdown
Contributor

@anntzer anntzer commented Feb 17, 2026

Ensure that QuiverKey.vector exists as soon as the constructor exits, rather than waiting for the first draw.

Deprecate the fontproperties, labelcolor, and verts attribute (overwriting them would not actually update the underlying artist (except before the first draw) anyways). Also deprecate kw (which could be updated with effect, but it seems simpler to directly update the underlying artist here too, if really needed; moreover the old version, which mutated self.Q.polykw in-place, likely led to weird side-effects e.g. if a key is first added to kw, a draw is triggered, mutating self.Q.polykw, then the key is removed).

Noted while reviewing #31169.

PR summary

PR checklist

Ensure that QuiverKey.vector exists as soon as the constructor exits,
rather than waiting for the first draw.

Deprecate the `fontproperties`, `labelcolor`, and `verts` attribute
(overwriting them would not actually update the underlying artist
(except before the first draw) anyways).  Also deprecate `kw` (which
*could* be updated with effect, but it seems simpler to directly update
the underlying artist here too, if really needed; moreover the old
version, which mutated `self.Q.polykw` *in-place*, likely led to weird
side-effects e.g. if a key is first added to `kw`, a draw is triggered,
mutating `self.Q.polykw`, then the key is removed).
@tacaswell tacaswell added this to the v3.11.0 milestone Feb 20, 2026
Comment on lines +378 to +379
if False: # self._dpi_at_last_init == self.axes.get_figure().dpi
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if False: # self._dpi_at_last_init == self.axes.get_figure().dpi
return

This code would never run?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left the old dead check (which was inverted as if True; I just swapped the boolean to dedent the whole block below), because maybe(?) it makes sense to not recompute the vertices at every draw, but only when they get invalidated (which seems to be the original intent). It's not clear why that code was commented out but perhaps we can figure that out another time.

Copy link
Copy Markdown
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo removing the dead code.

@ksunden ksunden merged commit 49b4bab into matplotlib:main Mar 6, 2026
53 of 55 checks passed
@anntzer anntzer deleted the qki branch March 6, 2026 21:45
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Mar 16, 2026
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants