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

Skip to content

Commit 0973a4e

Browse files
committed
Add rcParams to enable minor ticks:
could use `rcParams['xtick.minor.visible'] = True` to enable automatic minor ticks on x axis; refer to issue @3024 for details; Also update tests_axes based on this issue.
1 parent c90469b commit 0973a4e

8 files changed

+905
-0
lines changed

lib/matplotlib/axes/_base.py

Lines 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

Lines 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
Binary file not shown.

0 commit comments

Comments
 (0)