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

Skip to content

Fix xtick.minor.visible only acting on the xaxis #12938

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

Conversation

ImportanceOfBeingErnest
Copy link
Member

@ImportanceOfBeingErnest ImportanceOfBeingErnest commented Dec 6, 2018

PR Summary

#10193 introduced a bug, that when the rc param xtick.minor.visible is set to True, also the y-axis would get minor ticks.

import matplotlib.pyplot as plt
plt.rcParams["xtick.minor.visible"] =  True

plt.plot([1,2])
plt.show()

minorticks_bug

This PR fixes this.
with this PR

minorticks_fixed

Interestingly though, plt.rcParams["ytick.minor.visible"] = True always worked fine. So in that sense I'm not sure if the Scale would even need to set the locator the way it does.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@@ -69,7 +69,8 @@ def set_default_locators_and_formatters(self, axis):
axis.set_major_formatter(ScalarFormatter())
axis.set_minor_formatter(NullFormatter())
# update the minor locator for x and y axis based on rcParams
if rcParams['xtick.minor.visible']:
if axis.axis_name in list("xy") and \
rcParams['{}tick.minor.visible'.format(axis.axis_name)]:
Copy link
Member

@timhoffm timhoffm Dec 6, 2018

Choose a reason for hiding this comment

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

IMHO this would be slightly more readable:

if (axis.axis_name == 'x' and rcParams['xtick.minor.visible']
    or axis.axis_name == 'y' and rcParams['ytick.minor.visible']):

Copy link
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 adding a test.

Don't think we need an image test, just ask the axis if the minor ticks are turned on.

@ImportanceOfBeingErnest
Copy link
Member Author

Test added.

@timhoffm timhoffm merged commit 4b0196e into matplotlib:master Dec 10, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 10, 2018
QuLogic added a commit that referenced this pull request Dec 10, 2018
…938-on-v3.0.x

Backport PR #12938 on branch v3.0.x (Fix xtick.minor.visible only acting on the xaxis)
Stephen-Chilcote pushed a commit to Stephen-Chilcote/matplotlib that referenced this pull request Dec 11, 2018
raamana added a commit to raamana/matplotlib that referenced this pull request Dec 13, 2018
* upstream/master: (1723 commits)
  Correctly get weight & style hints from certain newer Microsoft fonts (matplotlib#12945)
  Remove some checks for Py<3.6 in the test suite. (matplotlib#12974)
  Fail-fast when trying to run tests with too-old pytest.
  Include scatter plots in Qt figure options editor. (matplotlib#12779)
  ENH: replace deprecated numpy header
  Minor simplifications.
  tickminorvisible-fix (matplotlib#12938)
  Remove animated=True from animation docs
  Update the documentation of Cursor
  Misc. cleanups.
  Add test for 3d conversion of empty PolyCollection
  Support ~ as nonbreaking space in mathtext.
  Deprecate public use of Formatter.pprint_val.
  MAINT: Unify calculation of normal vectors from polygons (matplotlib#12136)
  Fix the title of testing_api
  More table documentation
  Simplify bachelors degree example using new features.
  Avoid pyplot in showcase examples.
  Simplify argument checking in Table.__getitem__. (matplotlib#12932)
  Minor updates following bump to Py3.6+.
  ...

# Conflicts:
#	lib/matplotlib/widgets.py
@ImportanceOfBeingErnest ImportanceOfBeingErnest deleted the tickminorvisible-fix branch February 17, 2019 23:28
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.

3 participants