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

Skip to content

Commit cec9c33

Browse files
committed
Add test
1 parent 4146b21 commit cec9c33

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

lib/matplotlib/tests/test_axes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,21 @@ def test_nonfinite_limits():
779779
ax.plot(x, y)
780780

781781

782+
def test_limits_empty_data():
783+
# Check that plotting empty data doesn't change autoscaling of dates
784+
x = np.arange("2010-01-01", "2011-01-01", dtype="datetime64[D]")
785+
lims = (14591.8, 14992.2)
786+
787+
fig, ax = plt.subplots()
788+
ax.scatter(x, np.arange(len(x)))
789+
assert ax.get_xlim() == lims
790+
791+
fig, ax = plt.subplots()
792+
ax.scatter([], [])
793+
ax.scatter(x, np.arange(len(x)))
794+
assert ax.get_xlim() == lims
795+
796+
782797
@image_comparison(['imshow', 'imshow'], remove_text=True, style='mpl20')
783798
def test_imshow():
784799
# use former defaults to match existing baseline image

0 commit comments

Comments
 (0)