@@ -85,12 +85,31 @@ def test_date_empty():
8585 fig , ax = plt .subplots ()
8686 ax .xaxis_date ()
8787 fig .draw_no_output ()
88- np .testing .assert_allclose (ax .get_xlim (),
88+ np .testing .assert_allclose (ax .get_xlim (),
8989 [mdates .date2num (np .datetime64 ('2000-01-01' )),
9090 mdates .date2num (np .datetime64 ('2010-01-01' ))])
9191 mdates ._reset_epoch_test_example ()
9292
9393
94+ def test_axhline ():
95+ # make sure that axhline doesn't set the xlimits...
96+ fig , ax = plt .subplots ()
97+ ax .axhline (1.5 )
98+ ax .plot ([np .datetime64 ('2016-01-01' ), np .datetime64 ('2016-01-02' )], [1 , 2 ])
99+ np .testing .assert_allclose (ax .get_xlim (),
100+ [mdates .date2num (np .datetime64 ('2016-01-01' )),
101+ mdates .date2num (np .datetime64 ('2016-01-02' ))])
102+
103+ mdates ._reset_epoch_test_example ()
104+ mdates .set_epoch ('0000-12-31' )
105+ fig , ax = plt .subplots ()
106+ ax .axhline (1.5 )
107+ ax .plot ([np .datetime64 ('2016-01-01' ), np .datetime64 ('2016-01-02' )], [1 , 2 ])
108+ np .testing .assert_allclose (ax .get_xlim (),
109+ [mdates .date2num (np .datetime64 ('2016-01-01' )),
110+ mdates .date2num (np .datetime64 ('2016-01-02' ))])
111+ mdates ._reset_epoch_test_example ()
112+
94113
95114@image_comparison (['date_axhspan.png' ])
96115def test_date_axhspan ():
0 commit comments