Skip to content

Commit

Permalink
Merge pull request #4220 from crazym/master
Browse files Browse the repository at this point in the history
ENH : Add rcParams to enable/disable minor ticks on axes separately

Closes #3024
  • Loading branch information
tacaswell committed Mar 16, 2015
2 parents 0346946 + 88428eb commit a2fd30d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/users/whats_new/rcparams.rst
@@ -1,3 +1,9 @@
Added ``xtick.minor.visible`` and ``ytick.minor.visible`` key to rcParams
`````````````````````````````````````````````````````````````````````````
Two new keys to control the minor ticks on x/y axis respectively, default set to ``False`` (no minor ticks on the axis).

When ``True``, the minor ticks are shown and located via a ``mticker.AutoMinorLocator()``.

Added "legend.framealpha" key to rcParams
`````````````````````````````````````````
Added a key and the corresponding logic to control the default transparency of
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/axes/_base.py
Expand Up @@ -881,6 +881,13 @@ def cla(self):
else:
self.yaxis._set_scale('linear')

# update the minor locator for x and y axis based on rcParams
if (rcParams['xtick.minor.visible']):
self.xaxis.set_minor_locator(mticker.AutoMinorLocator())

if (rcParams['ytick.minor.visible']):
self.yaxis.set_minor_locator(mticker.AutoMinorLocator())

self._autoscaleXon = True
self._autoscaleYon = True
self._xmargin = rcParams['axes.xmargin']
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/rcsetup.py
Expand Up @@ -694,6 +694,8 @@ def __call__(self, s):
'xtick.major.pad': [4, validate_float], # distance to label in points
'xtick.minor.pad': [4, validate_float], # distance to label in points
'xtick.color': ['k', validate_color], # color of the xtick labels
'xtick.minor.visible': [False, validate_bool], # visiablility of the x axis minor ticks

# fontsize of the xtick labels
'xtick.labelsize': ['medium', validate_fontsize],
'xtick.direction': ['in', six.text_type], # direction of xticks
Expand All @@ -705,6 +707,8 @@ def __call__(self, s):
'ytick.major.pad': [4, validate_float], # distance to label in points
'ytick.minor.pad': [4, validate_float], # distance to label in points
'ytick.color': ['k', validate_color], # color of the ytick labels
'ytick.minor.visible': [False, validate_bool], # visiablility of the y axis minor ticks

# fontsize of the ytick labels
'ytick.labelsize': ['medium', validate_fontsize],
'ytick.direction': ['in', six.text_type], # direction of yticks
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -129,6 +129,17 @@ def test_twinx_cla():
assert_true(ax.yaxis.get_visible())


@image_comparison(baseline_images=["minorticks_on_rcParams_both"], extensions=['png'])
def test_minorticks_on_rcParams_both():

fig = plt.figure()
matplotlib.rcParams['xtick.minor.visible'] = True
matplotlib.rcParams['ytick.minor.visible'] = True

plt.plot([0, 1], [0, 1])
plt.axis([0, 1, 0, 1])


@image_comparison(baseline_images=["autoscale_tiny_range"], remove_text=True)
def test_autoscale_tiny_range():
# github pull #904
Expand Down

0 comments on commit a2fd30d

Please sign in to comment.