8000 Add rcParams to enable/disable minor ticks on axes separately issue #3024 by crazym · Pull Request #4220 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Add rcParams to enable/disable minor ticks on axes separately issue #3024 #4220

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
merged 1 commit into from
Mar 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add rcParams to enable minor ticks:
could use `rcParams['xtick.minor.visible'] = True` to enable automatic minor ticks on x axis;
update tests_axes;
update documentation on whats_new/rcParams.
Refer to issue @3024 for details.
  • Loading branch information
crazym committed Mar 16, 2015
commit 88428eb1d2ce84f7b4b2e602a92658fa6d22a81f
6 changes: 6 additions & 0 deletions doc/users/whats_new/rcparams.rst
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading
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
Original file line number Diff line number Diff line change
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