X Tutup
Skip to content

Commit decfbd1

Browse files
Break out tick visibility check into static method
1 parent 5ffd67e commit decfbd1

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

lib/matplotlib/axis.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,21 +1290,26 @@ def _set_artist_props(self, a):
12901290
return
12911291
a.set_figure(self.get_figure(root=False))
12921292

1293+
@staticmethod
1294+
def _tick_group_visible(kw):
1295+
"""
1296+
Check if any of the tick group components are visible.
1297+
Takes in self._major_tick_kw or self._minor_tick_kw.
1298+
"""
1299+
return (kw.get('tick1On') is not False or
1300+
kw.get('tick2On') is not False or
1301+
kw.get('label1On') is not False or
1302+
kw.get('label2On') is not False or
1303+
kw.get('gridOn') is not False)
1304+
12931305
def _update_ticks(self):
12941306
"""
12951307
Update ticks (position and labels) using the current data interval of
12961308
the axes. Return the list of ticks that will be drawn.
12971309
"""
12981310
# Check if major ticks should be computed.
12991311
# Skip if using NullLocator or if all visible components are off.
1300-
major_kw = self._major_tick_kw
1301-
major_visible = (major_kw.get('tick1On') is not False or
1302-
major_kw.get('tick2On') is not False or
1303-
major_kw.get('label1On') is not False or
1304-
major_kw.get('label2On') is not False or
1305-
major_kw.get('gridOn') is not False)
1306-
1307-
if (major_visible
1312+
if (self._tick_group_visible(self._major_tick_kw)
13081313
and not isinstance(self.get_major_locator(), NullLocator)):
13091314
major_locs = self.get_majorticklocs()
13101315
major_labels = self.major.formatter.format_ticks(major_locs)
@@ -1317,14 +1322,7 @@ def _update_ticks(self):
13171322
major_ticks = []
13181323

13191324
# Check if minor ticks should be computed.
1320-
minor_kw = self._minor_tick_kw
1321-
minor_visible = (minor_kw.get('tick1On') is not False or
1322-
minor_kw.get('tick2On') is not False or
1323-
minor_kw.get('label1On') is not False or
1324-
minor_kw.get('label2On') is not False or
1325-
minor_kw.get('gridOn') is not False)
1326-
1327-
if (minor_visible
1325+
if (self._tick_group_visible(self._minor_tick_kw)
13281326
and not isinstance(self.get_minor_locator(), NullLocator)):
13291327
minor_locs = self.get_minorticklocs()
13301328
minor_labels = self.minor.formatter.format_ticks(minor_locs)

0 commit comments

Comments
 (0)
X Tutup