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

Function test_colorbar_autoticks

lib/matplotlib/tests/test_colorbar.py:464–486  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

462
463
464def test_colorbar_autoticks():
465 # Test new autotick modes. Needs to be classic because
466 # non-classic doesn't go this route.
467 with rc_context({'_internal.classic_mode': False}):
468 fig, ax = plt.subplots(2, 1)
469 x = np.arange(-3.0, 4.001)
470 y = np.arange(-4.0, 3.001)
471 X, Y = np.meshgrid(x, y)
472 Z = X * Y
473 Z = Z[:-1, :-1]
474 pcm = ax[0].pcolormesh(X, Y, Z)
475 cbar = fig.colorbar(pcm, ax=ax[0], extend='both',
476 orientation='vertical')
477
478 pcm = ax[1].pcolormesh(X, Y, Z)
479 cbar2 = fig.colorbar(pcm, ax=ax[1], extend='both',
480 orientation='vertical', shrink=0.4)
481 # note only -10 to 10 are visible,
482 np.testing.assert_almost_equal(cbar.ax.yaxis.get_ticklocs(),
483 np.arange(-15, 16, 5))
484 # note only -10 to 10 are visible
485 np.testing.assert_almost_equal(cbar2.ax.yaxis.get_ticklocs(),
486 np.arange(-20, 21, 10))
487
488
489def test_colorbar_autotickslog():

Callers

nothing calls this directly

Calls 6

rc_contextFunction · 0.90
pcolormeshMethod · 0.80
assert_almost_equalMethod · 0.80
get_ticklocsMethod · 0.80
subplotsMethod · 0.45
colorbarMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…