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

Skip to content

Commit 6df9101

Browse files
committed
Add basic test for switching autoscale status.
1 parent 8005d8a commit 6df9101

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,6 +4105,24 @@ def test_violin_point_mass():
41054105
"""Violin plot should handle point mass pdf gracefully."""
41064106
plt.violinplot(np.array([0, 0]))
41074107

4108+
4109+
@cleanup
4110+
def test_autoscale():
4111+
plt.plot([0, 1], [0, 1])
4112+
assert_equal(plt.xlim(), (0, 1))
4113+
plt.autoscale(False)
4114+
plt.plot([2, 3], [2, 3])
4115+
assert_equal(plt.xlim(), (0, 1))
4116+
plt.autoscale(True)
4117+
plt.plot([1, 2], [1, 2])
4118+
assert_equal(plt.xlim(), (0, 3))
4119+
with plt.autoscale(False):
4120+
plt.plot([3, 4], [3, 4])
4121+
assert_equal(plt.xlim(), (0, 3))
4122+
plt.plot([4, 5], [4, 5])
4123+
assert_equal(plt.xlim(), (0, 5))
4124+
4125+
41084126
if __name__ == '__main__':
41094127
import nose
41104128
import sys

0 commit comments

Comments
 (0)