Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace ClabelText by set_transform_rotates_text. #24140

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
Oct 12, 2022

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 11, 2022

ContourLabeler previously optionally used a custom Text subclass to ensure that text rotation took place in data space, not in screen space, but this is now available for all Text instances via the transform_rotates_text property, so directly use that. This means that _get_label_text, _add_label, and set_label_props can also directly get inlined into their now only callsite (add_label).

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@@ -150,10 +151,8 @@ def clabel(self, levels=None, *,
or minus 90 degrees from level.

use_clabeltext : bool, default: False
Copy link
Member

Choose a reason for hiding this comment

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

Should one consider renaming this argument?

Copy link
Member

@oscargus oscargus left a comment

Choose a reason for hiding this comment

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

Makes sense. The kwarg can be renamed later (or now).

@anntzer
Copy link
Contributor Author

anntzer commented Oct 11, 2022

Let's defer that to another time.

@@ -273,6 +272,7 @@ def get_label_width(self, lev, fmt, fsize):
width *= 72 / fig.dpi
return width

@_api.deprecated("3.7", alternative="Artist.set")
Copy link
Member

Choose a reason for hiding this comment

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

The deprecation is a bit terse

I think

labeler.set_label_props(label, text, color)

is equivalent to

label.set(text=text, color=color, fontproperties=labeler.labelFontProps, clip_box(labeler.axes)

Which is not quite straight forward unless you check the source. Can we document this better (even only in the changelog would be ok).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, done.

ContourLabeler previously optionally used a custom Text subclass to
ensure that text rotation took place in data space, not in screen space,
but this is now available for all Text instances via the
transform_rotates_text property, so directly use that.  This means that
_get_label_text, _add_label, and set_label_props can also directly get
inlined into their now only callsite (add_label).
@QuLogic QuLogic merged commit 28bd24b into matplotlib:main Oct 12, 2022
@anntzer anntzer deleted the strt branch October 12, 2022 11:49
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.

4 participants