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

Function test_inverted_cla

lib/matplotlib/tests/test_axes.py:516–565  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

514
515
516def test_inverted_cla():
517 # GitHub PR #5450. Setting autoscale should reset
518 # axes to be non-inverted.
519 # plotting an image, then 1d graph, axis is now down
520 fig = plt.figure(0)
521 ax = fig.gca()
522 # 1. test that a new axis is not inverted per default
523 assert not ax.xaxis_inverted()
524 assert not ax.yaxis_inverted()
525 img = np.random.random((100, 100))
526 ax.imshow(img)
527 # 2. test that a image axis is inverted
528 assert not ax.xaxis_inverted()
529 assert ax.yaxis_inverted()
530 # 3. test that clearing and plotting a line, axes are
531 # not inverted
532 ax.cla()
533 x = np.linspace(0, 2*np.pi, 100)
534 ax.plot(x, np.cos(x))
535 assert not ax.xaxis_inverted()
536 assert not ax.yaxis_inverted()
537
538 # 4. autoscaling should not bring back axes to normal
539 ax.cla()
540 ax.imshow(img)
541 plt.autoscale()
542 assert not ax.xaxis_inverted()
543 assert ax.yaxis_inverted()
544
545 for ax in fig.axes:
546 ax.remove()
547 # 5. two shared axes. Inverting the leader axis should invert the shared
548 # axes; clearing the leader axis should bring axes in shared
549 # axes back to normal.
550 ax0 = plt.subplot(211)
551 ax1 = plt.subplot(212, sharey=ax0)
552 ax0.yaxis.set_inverted(True)
553 assert ax1.yaxis_inverted()
554 ax1.plot(x, np.cos(x))
555 ax0.cla()
556 assert not ax1.yaxis_inverted()
557 ax1.cla()
558 # 6. clearing the follower should not touch limits
559 ax0.imshow(img)
560 ax1.plot(x, np.cos(x))
561 ax1.cla()
562 assert ax.yaxis_inverted()
563
564 # clean up
565 plt.close(fig)
566
567
568def test_subclass_clear_cla():

Callers

nothing calls this directly

Calls 9

figureMethod · 0.80
gcaMethod · 0.80
imshowMethod · 0.80
set_invertedMethod · 0.80
claMethod · 0.45
plotMethod · 0.45
autoscaleMethod · 0.45
removeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…