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

Skip to content

Commit fc7c026

Browse files
committed
Added major/minor tick visibility params
1 parent c04e756 commit fc7c026

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

lib/matplotlib/axes/_base.py

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

575590
def __setstate__(self, state):
576591
self.__dict__ = state

lib/matplotlib/rcsetup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,12 @@ def validate_animation_writer_path(p):
11751175
'xtick.color': ['k', validate_color], # color of the xtick labels
11761176
'xtick.minor.visible': [False, validate_bool], # visiablility of the x axis minor ticks
11771177

1178+
'xtick.minor.top': [True, validate_bool], # visability of the x axis top minor ticks
1179+
'xtick.minor.bottom': [True, validate_bool], # visability of the x axis bottom minor ticks
1180+
'xtick.major.top': [True, validate_bool], # visability of the x axis top major ticks
1181+
'xtick.major.bottom': [True, validate_bool], # visability of the x axis bottom major ticks
1182+
1183+
11781184
# fontsize of the xtick labels
11791185
'xtick.labelsize': ['medium', validate_fontsize],
11801186
'xtick.direction': ['out', six.text_type], # direction of xticks
@@ -1190,6 +1196,11 @@ def validate_animation_writer_path(p):
11901196
'ytick.color': ['k', validate_color], # color of the ytick labels
11911197
'ytick.minor.visible': [False, validate_bool], # visiablility of the y axis minor ticks
11921198

1199+
'ytick.minor.left': [True, validate_bool], # visability of the y axis top minor ticks
1200+
'ytick.minor.right': [True, validate_bool], # visability of the y axis bottom minor ticks
1201+
'ytick.major.left': [True, validate_bool], # visability of the y axis top major ticks
1202+
'ytick.major.right': [True, validate_bool], # visability of the y axis bottom major ticks
1203+
11931204
# fontsize of the ytick labels
11941205
'ytick.labelsize': ['medium', validate_fontsize],
11951206
'ytick.direction': ['out', six.text_type], # direction of yticks

lib/matplotlib/tests/test_axes.py

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

41304130

4131+
@cleanup
4132+
def test_rc_major_minor_tick():
4133+
d = {'xtick.top': True, 'ytick.right': True, # Enable all ticks
4134+
'xtick.bottom': True, 'ytick.left': True,
4135+
# Selectively disable
4136+
'xtick.minor.bottom': False, 'xtick.major.bottom': False,
4137+
'ytick.major.left': False, 'ytick.minor.left': False}
4138+
with plt.rc_context(rc=d):
4139+
fig = plt.figure()
4140+
ax1 = fig.add_subplot(1, 1, 1)
4141+
xax = ax1.xaxis
4142+
yax = ax1.yaxis
4143+
# tick1On bottom/left
4144+
assert xax._major_tick_kw['tick1On'] == False
4145+
assert xax._major_tick_kw['tick2On'] == True
4146+
assert xax._minor_tick_kw['tick1On'] == False
4147+
assert xax._minor_tick_kw['tick2On'] == True
4148+
4149+
assert yax._major_tick_kw['tick1On'] == False
4150+
assert yax._major_tick_kw['tick2On'] == True
4151+
assert yax._minor_tick_kw['tick1On'] == False
4152+
assert yax._minor_tick_kw['tick2On'] == True
4153+
4154+
41314155
@cleanup
41324156
def test_bar_negative_width():
41334157
fig, ax = plt.subplots()

0 commit comments

Comments
 (0)