Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1db488

Browse files
committed
Added a test for #1553
1 parent ec84925 commit d1db488

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

lib/matplotlib/tests/test_axes.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,29 @@ def test_hexbin_extent():
419419

420420
ax.hexbin(x, y, extent=[.1, .3, .6, .7])
421421

422+
@cleanup
423+
def test_inverted_limits():
424+
# Test gh:1553
425+
# Calling invert_xaxis prior to plotting should not disable autoscaling
426+
# while still maintaining the inverted direction
427+
fig = plt.figure()
428+
ax = fig.gca()
429+
ax.invert_xaxis()
430+
ax.plot([-5, -3, 2, 4], [1, 2, -3, 5])
431+
432+
assert ax.get_xlim() == (4, -5)
433+
assert ax.get_ylim() == (-3, 5)
434+
plt.close()
435+
436+
fig = plt.figure()
437+
ax = fig.gca()
438+
ax.invert_yaxis()
439+
ax.plot([-5, -3, 2, 4], [1, 2, -3, 5])
440+
441+
assert ax.get_xlim() == (-5, 4)
442+
assert ax.get_ylim() == (5, -3)
443+
plt.close()
444+
422445
@image_comparison(baseline_images=['nonfinite_limits'])
423446
def test_nonfinite_limits():
424447
x = np.arange(0., np.e, 0.01)

0 commit comments

Comments
 (0)