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

Supportax.grid(visible=<bool>).#18769

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
QuLogic merged 1 commit intomatplotlib:masterfromanntzer:gridvisible
Oct 20, 2020
Merged

Conversation

anntzer
Copy link
Contributor

Remove the separate _gridOnMajor/_gridOnMinor attributes and store
visibility together with all other grid attributes in the
_major_tick_kw/_minor_tick_kw dicts under the "gridOn" key. This makes
it possible to update just that entry inAxis.grid.

Also, don't normalizeb to Trueif len(kwargs) inAxes.grid:
we need to keep it asNone, normalizing it only to True/False in
Axis.grid (which handles that just fine), so thatAxis.grid can
handle the consistency checks betweenb andvisible.

Closes#18758.

PR Summary

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings andpydocstyle<4 and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

Remove the separate _gridOnMajor/_gridOnMinor attributes and storevisibility together with all other grid attributes in the_major_tick_kw/_minor_tick_kw dicts under the "gridOn" key.  This makesit possible to update just that entry in `Axis.grid`.Also, don't normalize `b` to True `if len(kwargs)` in `Axes.grid`:we need to keep it as `None`, normalizing it only to True/False in`Axis.grid` (which handles that just fine), so that `Axis.grid` canhandle the consistency checks between `b` and `visible`.
@QuLogic
Copy link
Member

That issue was a regression from 3.2.2. Is this entire change necessary to fix it? I'm trying to determine whether this whole PR would need to go back, or some smaller version only.

@anntzer
Copy link
ContributorAuthor

anntzer commentedOct 20, 2020
edited
Loading

I didn't know it was a regression, so I have no idea whether there's a simpler fix...
(I do think kill _gridOnMajor/_gridOnMinor is a good idea at least for the long term, though.)

self.set_tick_params(which='minor', gridOn=self._gridOnMinor,
**gridkw)
if b is None and not forced_visibility:
gridkw['gridOn'] = not self._minor_tick_kw['gridOn']
Copy link
Member

Choose a reason for hiding this comment

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

Should this toggle the value in_minor_tick_kw?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

set_tick_params (called just below) does that.

"""
if len(kwargs):
if not b and b is not None: # something false-like but not None
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we instead renameb tovisible?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

b=None (== toggle) andvisible=None (== False) behave differently. I think all these toggling APIs are pretty terrible, but breaking all the scripts in the world that doax.grid() to toggle the grid on is just not worth it.

I guess wecould aim to have the end API bedef grid(visible=True, ...): (and deprecateb) though. Then the only case we'd break is people doingax.grid() to switch off the grid when the grid is already on, which is probably much less common (andax.grid(False) just seems much clearer). But let's keep that discussion for another time.

timhoffm 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.

Uh, it's worse than I thought.

@QuLogicQuLogic added this to thev3.3.3 milestoneOct 20, 2020
@QuLogicQuLogic merged commitd7fc51b intomatplotlib:masterOct 20, 2020
@lumberbot-app
Copy link

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.3.x$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 d7fc51b7d9adfcb537788b36d24ece420aa3f930
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #18769: Support `ax.grid(visible=<bool>)`.'
  1. Push to a named branch :
git push YOURFORK v3.3.x:auto-backport-of-pr-18769-on-v3.3.x
  1. Create a PR against branch v3.3.x, I would have named this PR:

"Backport PR#18769 on branch v3.3.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free tosuggest an improvement.

@anntzeranntzer deleted the gridvisible branchOctober 20, 2020 21:51
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestOct 21, 2020
tacaswell added a commit that referenced this pull requestOct 22, 2020
@Dapid
Copy link

This change has broken other packages. Is it really necessary to remove _gridOnMajor/_gridOnMinor?

Rubenkl and rayosborn reacted with thumbs up emoji

@jklymak
Copy link
Member

Do we really have no public interface to check whether the grid is on? Downstream libraries are now replacing the privateself.xaxis._gridOnMinor with the privateself.xaxis._minor_tick_kw["gridOn"], which seems even worse.

@jklymak
Copy link
Member

It would be helpful if other packages open an issue if they are stuck using a private attribute to access information they need.

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

@QuLogicQuLogicQuLogic approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.3.3
Development

Successfully merging this pull request may close these issues.

Using Axis.grid(visible=True) results in TypeError for multiple values for keyword argument
5 participants
@anntzer@QuLogic@Dapid@jklymak@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp