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 a2fd30d

Browse filesBrowse files
committed
Merge pull request #4220 from crazym/master
ENH : Add rcParams to enable/disable minor ticks on axes separately Closes #3024
2 parents 0346946 + 88428eb commit a2fd30d
Copy full SHA for a2fd30d

File tree

Expand file treeCollapse file tree

5 files changed

+28
-0
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+28
-0
lines changed

‎doc/users/whats_new/rcparams.rst

Copy file name to clipboardExpand all lines: doc/users/whats_new/rcparams.rst
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Added ``xtick.minor.visible`` and ``ytick.minor.visible`` key to rcParams
2+
`````````````````````````````````````````````````````````````````````````
3+
Two new keys to control the minor ticks on x/y axis respectively, default set to ``False`` (no minor ticks on the axis).
4+
5+
When ``True``, the minor ticks are shown and located via a ``mticker.AutoMinorLocator()``.
6+
17
Added "legend.framealpha" key to rcParams
28
`````````````````````````````````````````
39
Added a key and the corresponding logic to control the default transparency of

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,13 @@ def cla(self):
881881
else:
882882
self.yaxis._set_scale('linear')
883883

884+
# update the minor locator for x and y axis based on rcParams
885+
if (rcParams['xtick.minor.visible']):
886+
self.xaxis.set_minor_locator(mticker.AutoMinorLocator())
887+
888+
if (rcParams['ytick.minor.visible']):
889+
self.yaxis.set_minor_locator(mticker.AutoMinorLocator())
890+
884891
self._autoscaleXon = True
885892
self._autoscaleYon = True
886893
self._xmargin = rcParams['axes.xmargin']

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@ def __call__(self, s):
694694
'xtick.major.pad': [4, validate_float], # distance to label in points
695695
'xtick.minor.pad': [4, validate_float], # distance to label in points
696696
'xtick.color': ['k', validate_color], # color of the xtick labels
697+
'xtick.minor.visible': [False, validate_bool], # visiablility of the x axis minor ticks
698+
697699
# fontsize of the xtick labels
698700
'xtick.labelsize': ['medium', validate_fontsize],
699701
'xtick.direction': ['in', six.text_type], # direction of xticks
@@ -705,6 +707,8 @@ def __call__(self, s):
705707
'ytick.major.pad': [4, validate_float], # distance to label in points
706708
'ytick.minor.pad': [4, validate_float], # distance to label in points
707709
'ytick.color': ['k', validate_color], # color of the ytick labels
710+
'ytick.minor.visible': [False, validate_bool], # visiablility of the y axis minor ticks
711+
708712
# fontsize of the ytick labels
709713
'ytick.labelsize': ['medium', validate_fontsize],
710714
'ytick.direction': ['in', six.text_type], # direction of yticks
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ def test_twinx_cla():
129129
assert_true(ax.yaxis.get_visible())
130130

131131

132+
@image_comparison(baseline_images=["minorticks_on_rcParams_both"], extensions=['png'])
133+
def test_minorticks_on_rcParams_both():
134+
135+
fig = plt.figure()
136+
matplotlib.rcParams['xtick.minor.visible'] = True
137+
matplotlib.rcParams['ytick.minor.visible'] = True
138+
139+
plt.plot([0, 1], [0, 1])
140+
plt.axis([0, 1, 0, 1])
141+
142+
132143
@image_comparison(baseline_images=["autoscale_tiny_range"], remove_text=True)
133144
def test_autoscale_tiny_range():
134145
# github pull #904

0 commit comments

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