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

Fix get_tick_params#27408

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

Closed
StefRe wants to merge1 commit intomatplotlib:mainfromStefRe:fix/get_tick_params
Closed

Conversation

StefRe
Copy link
Contributor

@StefReStefRe commentedNov 30, 2023
edited
Loading

PR summary

Fix get_tick_params

  • show values for x axis too
  • fix nonfunctional test
  • move axis tests from test_axes.py to test_axis.py
  • make note inget_tick_params docstring more precise
  • addGridOn toset_tick_params as it's always returned byget_tick_params, so it would be illogical if you couldn't set the paramter in the setter

Closes#27416.

PR checklist

@@ -3394,6 +3394,8 @@ def tick_params(self, axis='both', **kwargs):
Width of gridlines in points.
grid_linestyle : str
Any valid `.Line2D` line style spec.
gridOn : bool
Copy link
Member

Choose a reason for hiding this comment

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

I'm hesitant to further expand the use of camelcase variables. But I don't have an overview of its usage and whethergrid_on would be a viable alternative. (No code editor access right now).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

grid_on would be available as an alternative.gridOn is only used internally in 4 files, no big deal to rename.

As an alternative one could translategridOn togrid_on (which wouldn't, however, prevent anyone to use the then undocumented keyword inset_tick_params etc., as it's the case now).

If we don't want to havegridOn I'd opt for renaming it togrid_on. This wouldn't be an API change asgridOn is not documented.

@@ -0,0 +1,8 @@
Classes derived from Axis must implement get_tick_params
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be sufficient to implement the translation, either as a dict or as_translate_tick_params()?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure, but_translate_tick_params is 18 LOC (not counting continuation lines) whereasget_tick_params is just 2.

Another thing is that set/get_tick_params currently doesn't work correctly for Axes3D (I'm going to open an issue about it) and I assume that it's easier fix with dedicated setters/getters (didn't look into it closely yet)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

On second thought, I think you're right and it's less convoluted to make the translation dicts axis-specific in the first place rather than modify a generic dict. I'll change it later this week, changing this PR to draft in the meantime.

timhoffm reacted with thumbs up emoji
- show values for x axis too- fix nonfunctional test- move axis tests from test_axes.py to test_axis.py- make note in get_tick_params docstring more precise- add GridOn to set_tick_params as it's always returned by  get_tick_params, so it would be illogical if you couldn't  set the paramter in the setter
@StefRe
Copy link
ContributorAuthor

This re-write of the Note in theget_tick_params documentation was caused by this example:

importmatplotlib.pyplotaspltimportmatplotlibasmplwithmpl.rc_context({"ytick.labelcolor":"blue"}):fig,ax=plt.subplots()forlabelinax.get_xticklabels():label.set_fontweight("bold")plt.xticks(ha="left")fig.text(0.2,0.7,"\n".join(["___x___"]+ [f"{k}:{v}"fork,vinax.xaxis.get_tick_params().items()]),va="top")fig.text(0.6,0.7,"\n".join(["___y___"]+ [f"{k}:{v}"fork,vinax.yaxis.get_tick_params().items()]),va="top")plt.show()

get_params

This shows that

  • neither the label color nor the horizontal alignement are returned byget_tick_params although the were not set via the set_* methods on the individual tick objects
  • the bold fontweight set on the individual tick labels is also applied tonew labels (the warning atget_major_ticks is correct as it says that there'sa risk that the changes will not survive, it doesn't claim that these changes only apply to current labels.

@StefReStefRe marked this pull request as ready for reviewDecember 1, 2023 13:59
@StefReStefRe marked this pull request as draftDecember 4, 2023 07:11
.. note::
This method only returns the values of the parameters *bottom*, *top*,
*labelbottom*, *labeltop* or *left*, *right*, *labelleft*, *labelright*,
respectively, and *girdOn* as well as all additional parameters that were
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
respectively,and*girdOn*aswellasalladditionalparametersthatwere
respectively,and*gridOn*aswellasalladditionalparametersthatwere

@timhoffm
Copy link
Member

I believe this has been superseeded by#29249.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ksundenksundenksunden left review comments

@timhoffmtimhoffmtimhoffm left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Bug]: get_tick_params on xaxis shows wrong keywords
5 participants
@StefRe@timhoffm@ksunden@QuLogic@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp