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

Skip to content

Commit 4721d2e

Browse files
tacaswellQuLogic
authored andcommitted
Merge pull request #6735 from bcongdon/feature_rcParam_side_tick
ENH: Added missing side tick rcParams
1 parent d42e3e9 commit 4721d2e

File tree

6 files changed

+67
-6
lines changed

6 files changed

+67
-6
lines changed

doc/users/whats_new/ticks_rcparams.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The parameters ``xtick.top``, ``xtick.bottom``, ``ytick.left``
55
and ``ytick.right`` were added to control where the ticks
66
are drawn.
77

8+
Furthermore, the parameters ``xtick.major.top``, ``xtick.major.bottom``,
9+
``xtick.minor.top``, ``xtick.minor.bottom``, ``ytick.major.left``,
10+
``ytick.major.right``, ``ytick.minor.left``, and ``ytick.minor.right`` were
11+
added to control were ticks are drawn.
12+
813
``hist.bins`` to control the default number of bins to use in
914
`~matplotlib.axes.Axes.hist`. This can be an `int`, a list of floats, or
1015
``'auto'`` if numpy >= 1.11 is installed.

lib/matplotlib/axes/_base.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,20 @@ def __init__(self, fig, rect,
567567
if self.yaxis is not None:
568568
self._ycid = self.yaxis.callbacks.connect('units finalize',
569569
self.relim)
570-
self.tick_params(top=rcParams['xtick.top'],
571-
bottom=rcParams['xtick.bottom'],
572-
left=rcParams['ytick.left'],
573-
right=rcParams['ytick.right'],
574-
which='both')
570+
571+
self.tick_params(
572+
top=rcParams['xtick.top'] and rcParams['xtick.minor.top'],
573+
bottom=rcParams['xtick.bottom'] and rcParams['xtick.minor.bottom'],
574+
left=rcParams['ytick.left'] and rcParams['ytick.minor.left'],
575+
right=rcParams['ytick.right'] and rcParams['ytick.minor.right'],
576+
which='minor')
577+
578+
self.tick_params(
579+
top=rcParams['xtick.top'] and rcParams['xtick.major.top'],
580+
bottom=rcParams['xtick.bottom'] and rcParams['xtick.major.bottom'],
581+
left=rcParams['ytick.left'] and rcParams['ytick.major.left'],
582+
right=rcParams['ytick.right'] and rcParams['ytick.major.right'],
583+
which='major')
575584

576585
def __setstate__(self, state):
577586
self.__dict__ = state

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ xtick.minor.pad : 4 # distance to the minor tick label in points
243243
xtick.color : k # color of the tick labels
244244
xtick.labelsize : medium # fontsize of the tick labels
245245
xtick.direction : in # direction: in, out, or inout
246+
xtick.major.top : True # draw x axis top major ticks
247+
xtick.major.bottom : True # draw x axis bottom major ticks
248+
xtick.minor.top : True # draw x axis top minor ticks
249+
xtick.minor.bottom : True # draw x axis bottom minor ticks
246250

247251
ytick.left : True # draw ticks on the left side
248252
ytick.right : True # draw ticks on the right side
@@ -256,7 +260,10 @@ ytick.minor.pad : 4 # distance to the minor tick label in points
256260
ytick.color : k # color of the tick labels
257261
ytick.labelsize : medium # fontsize of the tick labels
258262
ytick.direction : in # direction: in, out, or inout
259-
263+
ytick.major.left : True # draw y axis left major ticks
264+
ytick.major.right : True # draw y axis right major ticks
265+
ytick.minor.left : True # draw y axis left minor ticks
266+
ytick.minor.right : True # draw y axis right minor ticks
260267

261268
### GRIDS
262269
grid.color : k # grid color

lib/matplotlib/rcsetup.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,10 @@ def validate_hist_bins(s):
11591159
'xtick.minor.pad': [3.4, validate_float], # distance to label in points
11601160
'xtick.color': ['k', validate_color], # color of the xtick labels
11611161
'xtick.minor.visible': [False, validate_bool], # visiablility of the x axis minor ticks
1162+
'xtick.minor.top': [True, validate_bool], # draw x axis top minor ticks
1163+
'xtick.minor.bottom': [True, validate_bool], # draw x axis bottom minor ticks
1164+
'xtick.major.top': [True, validate_bool], # draw x axis top major ticks
1165+
'xtick.major.bottom': [True, validate_bool], # draw x axis bottom major ticks
11621166

11631167
# fontsize of the xtick labels
11641168
'xtick.labelsize': ['medium', validate_fontsize],
@@ -1174,6 +1178,10 @@ def validate_hist_bins(s):
11741178
'ytick.minor.pad': [3.4, validate_float], # distance to label in points
11751179
'ytick.color': ['k', validate_color], # color of the ytick labels
11761180
'ytick.minor.visible': [False, validate_bool], # visiablility of the y axis minor ticks
1181+
'ytick.minor.left': [True, validate_bool], # draw y axis left minor ticks
1182+
'ytick.minor.right': [True, validate_bool], # draw y axis right minor ticks
1183+
'ytick.major.left': [True, validate_bool], # draw y axis left major ticks
1184+
'ytick.major.right': [True, validate_bool], # draw y axis right major ticks
11771185

11781186
# fontsize of the ytick labels
11791187
'ytick.labelsize': ['medium', validate_fontsize],

lib/matplotlib/tests/test_axes.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4136,6 +4136,30 @@ def test_rc_tick():
41364136
assert yax._minor_tick_kw['tick2On'] == False
41374137

41384138

4139+
@cleanup
4140+
def test_rc_major_minor_tick():
4141+
d = {'xtick.top': True, 'ytick.right': True, # Enable all ticks
4142+
'xtick.bottom': True, 'ytick.left': True,
4143+
# Selectively disable
4144+
'xtick.minor.bottom': False, 'xtick.major.bottom': False,
4145+
'ytick.major.left': False, 'ytick.minor.left': False}
4146+
with plt.rc_context(rc=d):
4147+
fig = plt.figure()
4148+
ax1 = fig.add_subplot(1, 1, 1)
4149+
xax = ax1.xaxis
4150+
yax = ax1.yaxis
4151+
# tick1On bottom/left
4152+
assert xax._major_tick_kw['tick1On'] == False
4153+
assert xax._major_tick_kw['tick2On'] == True
4154+
assert xax._minor_tick_kw['tick1On'] == False
4155+
assert xax._minor_tick_kw['tick2On'] == True
4156+
4157+
assert yax._major_tick_kw['tick1On'] == False
4158+
assert yax._major_tick_kw['tick2On'] == True
4159+
assert yax._minor_tick_kw['tick1On'] == False
4160+
assert yax._minor_tick_kw['tick2On'] == True
4161+
4162+
41394163
@cleanup
41404164
def test_bar_negative_width():
41414165
fig, ax = plt.subplots()

matplotlibrc.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ backend : $TEMPLATE_BACKEND
373373
#xtick.labelsize : medium # fontsize of the tick labels
374374
#xtick.direction : out # direction: in, out, or inout
375375
#xtick.minor.visible : False # visibility of minor ticks on x-axis
376+
#xtick.major.top : True # draw x axis top major ticks
377+
#xtick.major.bottom : True # draw x axis bottom major ticks
378+
#xtick.minor.top : True # draw x axis top minor ticks
379+
#xtick.minor.bottom : True # draw x axis bottom minor ticks
376380

377381
#ytick.left : True # draw ticks on the left side
378382
#ytick.right : False # draw ticks on the right side
@@ -386,6 +390,10 @@ backend : $TEMPLATE_BACKEND
386390
#ytick.labelsize : medium # fontsize of the tick labels
387391
#ytick.direction : out # direction: in, out, or inout
388392
#ytick.minor.visible : False # visibility of minor ticks on y-axis
393+
#xtick.major.left : True # draw y axis left major ticks
394+
#xtick.major.right : True # draw y axis right major ticks
395+
#xtick.minor.left : True # draw y axis left minor ticks
396+
#xtick.minor.right : True # draw y axis right minor ticks
389397

390398

391399
### GRIDS

0 commit comments

Comments
 (0)