Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tick label font family via tick_params#25746

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 2 commits intomatplotlib:mainfromsaranti:labelfont
May 17, 2023

Conversation

saranti
Copy link
Contributor

PR Summary

Closes#18425. Added alabelfont kwarg to change tick label fonts conveniently, without changing the rest of the text.

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (andpytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

@@ -36,6 +36,7 @@ class Tick(martist.Artist):
pad: float | None = ...,
labelsize: float | None = ...,
labelcolor: ColorType | None = ...,
labelFont: Sequence[str] = ...,
Copy link
Member

Choose a reason for hiding this comment

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

I think you are conflating "font" with "font family" here. These are two different properties with different types expected. The former is an Alias of "fontproperties" and accepts afont_manager.FontProperties object as well as a few other options to pass into the constructor thereof. The latter acceptsstr | Iterable[str]

Both behave equivalently when passed a str, as in your test, but font also allows setting other attributes of the font, such as size and color.

Also your indentation and capitalization are not consistent here.
And this is (surprisingly) the first reference to Sequence (or Iterable) in this file so whichever is used (if kept) should be imported from collections.abc.

saranti reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I think for consistency, it should likely be spelled out that this is setting thelabelfontfamily (if that is the type you expect to pass) or thelabelfontproperties (as it is implemented, in which case the type hint should match that underlying Text setter).

Further, though if you do keep it aslabelfontfamily, it does need to be type hinted asstr | Sequence[str] | None (str because that is what you actually pass in the test,None because None is the default)

saranti reacted with thumbs up emoji
@@ -175,11 +175,11 @@ def __init__(
self.label1 = mtext.Text(
np.nan, np.nan,
fontsize=labelsize, color=labelcolor, visible=label1On,
fontproperties=labelfont, rotation=self._labelrotation[1])
fontproperties=labelfontfamily, rotation=self._labelrotation[1])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fontproperties=labelfontfamily,rotation=self._labelrotation[1])
fontfamily=labelfontfamily,rotation=self._labelrotation[1])

self.label2 = mtext.Text(
np.nan, np.nan,
fontsize=labelsize, color=labelcolor, visible=label2On,
fontproperties=labelfont, rotation=self._labelrotation[1])
fontproperties=labelfontfamily, rotation=self._labelrotation[1])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fontproperties=labelfontfamily,rotation=self._labelrotation[1])
fontfamily=labelfontfamily,rotation=self._labelrotation[1])


.. code-block:: python

Axis.tick_params(labelfont='monospace')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Axis.tick_params(labelfont='monospace')
Axis.tick_params(labelfontfamily='monospace')

saranti reacted with eyes emoji
Copy link
Member

@ksundenksunden left a comment

Choose a reason for hiding this comment

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

Modulo the extra character in the what's new doc

@timhoffmtimhoffm added this to thev3.8.0 milestoneMay 17, 2023
@timhoffmtimhoffm merged commit2466ccb intomatplotlib:mainMay 17, 2023
@sarantisaranti deleted the labelfont branchJune 23, 2023 10:54
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@oscargusoscargusoscargus left review comments

@ksundenksundenksunden approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.8.0
Development

Successfully merging this pull request may close these issues.

Add fontfamily/labelfont to tick_params
4 participants
@saranti@ksunden@timhoffm@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp