MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _update_ticks

Method _update_ticks

lib/matplotlib/axis.py:1335–1400  ·  view source on GitHub ↗

Update ticks (position and labels) using the current data interval of the axes. Return the list of ticks that will be drawn.

(self)

Source from the content-addressed store, hash-verified

1333 kw.get('gridOn') is not False)
1334
1335 def _update_ticks(self):
1336 """
1337 Update ticks (position and labels) using the current data interval of
1338 the axes. Return the list of ticks that will be drawn.
1339 """
1340 # Check if major ticks should be computed.
1341 # Skip if using NullLocator or if all visible components are off.
1342 if (self._tick_group_visible(self._major_tick_kw)
1343 and not isinstance(self.get_major_locator(), NullLocator)):
1344 major_locs = self.get_majorticklocs()
1345 major_labels = self.major.formatter.format_ticks(major_locs)
1346 major_ticks = self.get_major_ticks(len(major_locs))
1347 for tick, loc, label in zip(major_ticks, major_locs, major_labels):
1348 tick.update_position(loc)
1349 tick.label1.set_text(label)
1350 tick.label2.set_text(label)
1351 else:
1352 major_ticks = []
1353
1354 # Check if minor ticks should be computed.
1355 if (self._tick_group_visible(self._minor_tick_kw)
1356 and not isinstance(self.get_minor_locator(), NullLocator)):
1357 minor_locs = self.get_minorticklocs()
1358 minor_labels = self.minor.formatter.format_ticks(minor_locs)
1359 minor_ticks = self.get_minor_ticks(len(minor_locs))
1360 for tick, loc, label in zip(minor_ticks, minor_locs, minor_labels):
1361 tick.update_position(loc)
1362 tick.label1.set_text(label)
1363 tick.label2.set_text(label)
1364 else:
1365 minor_ticks = []
1366
1367 ticks = [*major_ticks, *minor_ticks]
1368 if not ticks:
1369 return []
1370
1371 view_low, view_high = self.get_view_interval()
1372 if view_low > view_high:
1373 view_low, view_high = view_high, view_low
1374
1375 if (hasattr(self, "axes") and self.axes.name == '3d'
1376 and mpl.rcParams['axes3d.automargin']):
1377 # In mpl3.8, the margin was 1/48. Due to the change in automargin
1378 # behavior in mpl3.9, we need to adjust this to compensate for a
1379 # zoom factor of 2/48, giving us a 23/24 modifier. So the new
1380 # margin is 0.019965277777777776 = 1/48*23/24.
1381 margin = 0.019965277777777776
1382 delta = view_high - view_low
1383 view_high = view_high - delta * margin
1384 view_low = view_low + delta * margin
1385
1386 interval_t = self.get_transform().transform([view_low, view_high])
1387
1388 ticks_to_draw = []
1389 for tick in ticks:
1390 try:
1391 loc_t = self.get_transform().transform(tick.get_loc())
1392 except AssertionError:

Callers 10

_draw_ticksMethod · 0.95
draw_gridMethod · 0.95
get_tightbboxMethod · 0.95
drawMethod · 0.95
get_majorticklabelsMethod · 0.95
get_minorticklabelsMethod · 0.95
get_window_extentMethod · 0.45
test_log_scalesFunction · 0.45
test_offset_valueMethod · 0.45

Calls 14

_tick_group_visibleMethod · 0.95
get_major_locatorMethod · 0.95
get_majorticklocsMethod · 0.95
get_major_ticksMethod · 0.95
get_minor_locatorMethod · 0.95
get_minorticklocsMethod · 0.95
get_minor_ticksMethod · 0.95
get_view_intervalMethod · 0.95
get_transformMethod · 0.95
get_locMethod · 0.80
format_ticksMethod · 0.45
update_positionMethod · 0.45

Tested by 2

test_log_scalesFunction · 0.36
test_offset_valueMethod · 0.36