@@ -83,6 +83,36 @@ def test_too_many_date_ticks():
8383 ax .xaxis .set_major_locator (DayLocator ())
8484 assert_raises (RuntimeError , fig .savefig , 'junk.png' )
8585
86+ @image_comparison (baseline_images = ['RRuleLocator_bounds' ])
87+ def test_RRuleLocator ():
88+ import pylab
89+ import matplotlib .dates as mpldates
90+ import matplotlib .testing .jpl_units as units
91+ from datetime import datetime
92+ import dateutil
93+ units .register ()
94+
95+ # This will cause the RRuleLocator to go out of bounds when it tries
96+ # to add padding to the limits, so we make sure it caps at the correct
97+ # boundary values.
98+ t0 = datetime ( 1000 , 1 , 1 )
99+ tf = datetime ( 6000 , 1 , 1 )
100+
101+ fig = pylab .figure ()
102+ ax = pylab .subplot ( 111 )
103+ ax .set_autoscale_on ( True )
104+ ax .plot ( [t0 , tf ], [0.0 , 1.0 ], marker = 'o' )
105+
106+ rrule = mpldates .rrulewrapper ( dateutil .rrule .YEARLY , interval = 500 )
107+ locator = mpldates .RRuleLocator ( rrule )
108+ ax .xaxis .set_major_locator ( locator )
109+ ax .xaxis .set_major_formatter ( mpldates .AutoDateFormatter (locator ) )
110+
111+ ax .autoscale_view ()
112+ fig .autofmt_xdate ()
113+
114+ fig .savefig ( 'RRuleLocator_bounds' )
115+
86116if __name__ == '__main__' :
87117 import nose
88118 nose .runmodule (argv = ['-s' ,'--with-doctest' ], exit = False )
0 commit comments