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

Appearance settings

Commit 4261e83

Browse filesBrowse files
authored
Merge pull request #12964 from meeseeksmachine/auto-backport-of-pr-12938-on-v3.0.x
Backport PR #12938 on branch v3.0.x (Fix xtick.minor.visible only acting on the xaxis)
2 parents cbf15b2 + 82f7ce2 commit 4261e83
Copy full SHA for 4261e83

File tree

Expand file treeCollapse file tree

2 files changed

+20
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-1
lines changed

‎lib/matplotlib/scale.py

Copy file name to clipboardExpand all lines: lib/matplotlib/scale.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def set_default_locators_and_formatters(self, axis):
6969
axis.set_major_formatter(ScalarFormatter())
7070
axis.set_minor_formatter(NullFormatter())
7171
# update the minor locator for x and y axis based on rcParams
72-
if rcParams['xtick.minor.visible']:
72+
if (axis.axis_name == 'x' and rcParams['xtick.minor.visible']
73+
or axis.axis_name == 'y' and rcParams['ytick.minor.visible']):
7374
axis.set_minor_locator(AutoMinorLocator())
7475
else:
7576
axis.set_minor_locator(NullLocator())

‎lib/matplotlib/tests/test_ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,3 +839,21 @@ def test_minlocator_type():
839839
fig, ax = plt.subplots()
840840
with pytest.raises(TypeError):
841841
ax.xaxis.set_minor_locator(matplotlib.ticker.LogFormatter())
842+
843+
844+
def test_minorticks_rc():
845+
fig = plt.figure()
846+
847+
def minorticksubplot(xminor, yminor, i):
848+
rc = {'xtick.minor.visible': xminor,
849+
'ytick.minor.visible': yminor}
850+
with plt.rc_context(rc=rc):
851+
ax = fig.add_subplot(2, 2, i)
852+
853+
assert (len(ax.xaxis.get_minor_ticks()) > 0) == xminor
854+
assert (len(ax.yaxis.get_minor_ticks()) > 0) == yminor
855+
856+
minorticksubplot(False, False, 1)
857+
minorticksubplot(True, False, 2)
858+
minorticksubplot(False, True, 3)
859+
minorticksubplot(True, True, 4)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.