11import datetime
22import numpy as np
3- import matplotlib
4- matplotlib .use ('Agg' )
53from matplotlib .testing .decorators import image_comparison
64import matplotlib .pyplot as plt
75
8- @image_comparison (baseline_images = ['empty_datetime .png' ])
9- def test_empty_datetime ():
6+ @image_comparison (baseline_images = ['date_empty .png' ])
7+ def test_date_empty ():
108 # make sure mpl does the right thing when told to plot dates even
119 # if no date data has been presented, cf
1210 # http://sourceforge.net/tracker/?func=detail&aid=2850075&group_id=80706&atid=560720
1311 fig = plt .figure ()
1412 ax = fig .add_subplot (1 ,1 ,1 )
1513 ax .xaxis_date ()
16- fig .savefig ('empty_datetime .png' )
14+ fig .savefig ('date_empty .png' )
1715
1816@image_comparison (baseline_images = ['date_axhspan.png' ])
1917def test_date_axhspan ():
@@ -23,9 +21,9 @@ def test_date_axhspan():
2321 fig = plt .figure ()
2422 ax = fig .add_subplot (1 ,1 ,1 )
2523 ax .axhspan ( t0 , tf , facecolor = "blue" , alpha = 0.25 )
26- ax .set_xlim (t0 - datetime .timedelta (days = 5 ),
24+ ax .set_ylim (t0 - datetime .timedelta (days = 5 ),
2725 tf + datetime .timedelta (days = 5 ))
28- fig .autofmt_xdate ( )
26+ fig .subplots_adjust ( left = 0.25 )
2927 fig .savefig ('date_axhspan.png' )
3028
3129@image_comparison (baseline_images = ['date_axvspan.png' ])
@@ -36,8 +34,8 @@ def test_date_axvspan():
3634 fig = plt .figure ()
3735 ax = fig .add_subplot (1 ,1 ,1 )
3836 ax .axvspan ( t0 , tf , facecolor = "blue" , alpha = 0.25 )
39- ax .set_xlim (t0 - datetime .timedelta (days = 5 ),
40- tf + datetime .timedelta (days = 5 ))
37+ ax .set_xlim (t0 - datetime .timedelta (days = 720 ),
38+ tf + datetime .timedelta (days = 720 ))
4139 fig .autofmt_xdate ()
4240 fig .savefig ('date_axvspan.png' )
4341
@@ -49,20 +47,20 @@ def test_date_axhline():
4947 tf = datetime .datetime (2009 , 1 , 31 )
5048 fig = plt .figure ()
5149 ax = fig .add_subplot (1 ,1 ,1 )
52- ax .axhline ( t0 , tf , facecolor = "blue" , lw = 3 )
53- ax .set_xlim (t0 - datetime .timedelta (days = 5 ),
50+ ax .axhline ( t0 , color = "blue" , lw = 3 )
51+ ax .set_ylim (t0 - datetime .timedelta (days = 5 ),
5452 tf + datetime .timedelta (days = 5 ))
55- fig .autofmt_xdate ( )
53+ fig .subplots_adjust ( left = 0.25 )
5654 fig .savefig ('date_axhline.png' )
5755
5856@image_comparison (baseline_images = ['date_axvline.png' ])
5957def test_date_axvline ():
6058 # test ax hline with date inputs
6159 t0 = datetime .datetime (2000 , 1 , 20 )
62- tf = datetime .datetime (2010 , 1 , 21 )
60+ tf = datetime .datetime (2000 , 1 , 21 )
6361 fig = plt .figure ()
6462 ax = fig .add_subplot (1 ,1 ,1 )
65- ax .axvline ( t0 , tf , facecolor = "blue " , lw = 3 )
63+ ax .axvline ( t0 , color = "red " , lw = 3 )
6664 ax .set_xlim (t0 - datetime .timedelta (days = 5 ),
6765 tf + datetime .timedelta (days = 5 ))
6866 fig .autofmt_xdate ()
@@ -74,3 +72,4 @@ def test_date_axvline():
7472 nose .runmodule (argv = ['-s' ,'--with-doctest' ], exit = False )
7573
7674
75+
0 commit comments