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

Function test_autofmt_xdate

lib/matplotlib/tests/test_figure.py:480–516  ·  view source on GitHub ↗
(which)

Source from the content-addressed store, hash-verified

478
479@pytest.mark.parametrize('which', ['both', 'major', 'minor'])
480def test_autofmt_xdate(which):
481 date = ['3 Jan 2013', '4 Jan 2013', '5 Jan 2013', '6 Jan 2013',
482 '7 Jan 2013', '8 Jan 2013', '9 Jan 2013', '10 Jan 2013',
483 '11 Jan 2013', '12 Jan 2013', '13 Jan 2013', '14 Jan 2013']
484
485 time = ['16:44:00', '16:45:00', '16:46:00', '16:47:00', '16:48:00',
486 '16:49:00', '16:51:00', '16:52:00', '16:53:00', '16:55:00',
487 '16:56:00', '16:57:00']
488
489 angle = 60
490 minors = [1, 2, 3, 4, 5, 6, 7]
491
492 x = mdates.datestr2num(date)
493 y = mdates.datestr2num(time)
494
495 fig, ax = plt.subplots()
496
497 ax.plot(x, y)
498 ax.yaxis_date()
499 ax.xaxis_date()
500
501 ax.xaxis.set_minor_locator(AutoMinorLocator(2))
502 with warnings.catch_warnings():
503 warnings.filterwarnings(
504 'ignore',
505 'FixedFormatter should only be used together with FixedLocator')
506 ax.xaxis.set_minor_formatter(FixedFormatter(minors))
507
508 fig.autofmt_xdate(0.2, angle, 'right', which)
509
510 if which in ('both', 'major'):
511 for label in fig.axes[0].get_xticklabels(False, 'major'):
512 assert int(label.get_rotation()) == angle
513
514 if which in ('both', 'minor'):
515 for label in fig.axes[0].get_xticklabels(True, 'minor'):
516 assert int(label.get_rotation()) == angle
517
518
519def test_autofmt_xdate_colorbar_constrained():

Callers

nothing calls this directly

Calls 8

AutoMinorLocatorClass · 0.90
FixedFormatterClass · 0.90
set_minor_locatorMethod · 0.80
set_minor_formatterMethod · 0.80
autofmt_xdateMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
get_rotationMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…