@@ -951,45 +951,37 @@ def _update_ticks(self, renderer):
951951 """
952952
953953 interval = self .get_view_interval ()
954- tick_tups = [ t for t in self .iter_ticks ()]
954+ tick_tups = list ( self .iter_ticks ())
955955 if self ._smart_bounds :
956956 # handle inverted limits
957- view_low , view_high = min (* interval ), max (* interval )
958- data_low , data_high = self .get_data_interval ()
959- if data_low > data_high :
960- data_low , data_high = data_high , data_low
961- locs = [ti [1 ] for ti in tick_tups ]
962- locs .sort ()
963- locs = np .array (locs )
964- if len (locs ):
965- if data_low <= view_low :
966- # data extends beyond view, take view as limit
967- ilow = view_low
957+ view_low , view_high = min (interval ), max (interval )
958+ data_low , data_high = sorted (self .get_data_interval ())
959+ locs = np .sort ([ti [1 ] for ti in tick_tups ])
960+ if data_low <= view_low :
961+ # data extends beyond view, take view as limit
962+ ilow = view_low
963+ else :
964+ # data stops within view, take best tick
965+ good_locs = locs [locs <= data_low ]
966+ if len (good_locs ) > 0 :
967+ # last tick prior or equal to first data point
968+ ilow = good_locs [- 1 ]
968969 else :
969- # data stops within view, take best tick
970- cond = locs <= data_low
971- good_locs = locs [cond ]
972- if len (good_locs ) > 0 :
973- # last tick prior or equal to first data point
974- ilow = good_locs [- 1 ]
975- else :
976- # No ticks (why not?), take first tick
977- ilow = locs [0 ]
978- if data_high >= view_high :
979- # data extends beyond view, take view as limit
980- ihigh = view_high
970+ # No ticks (why not?), take first tick
971+ ilow = locs [0 ]
972+ if data_high >= view_high :
973+ # data extends beyond view, take view as limit
974+ ihigh = view_high
975+ else :
976+ # data stops within view, take best tick
977+ good_locs = locs [locs >= data_high ]
978+ if len (good_locs ) > 0 :
979+ # first tick after or equal to last data point
980+ ihigh = good_locs [0 ]
981981 else :
982- # data stops within view, take best tick
983- cond = locs >= data_high
984- good_locs = locs [cond ]
985- if len (good_locs ) > 0 :
986- # first tick after or equal to last data point
987- ihigh = good_locs [0 ]
988- else :
989- # No ticks (why not?), take last tick
990- ihigh = locs [- 1 ]
991- tick_tups = [ti for ti in tick_tups
992- if (ti [1 ] >= ilow ) and (ti [1 ] <= ihigh )]
982+ # No ticks (why not?), take last tick
983+ ihigh = locs [- 1 ]
984+ tick_tups = [ti for ti in tick_tups if ilow <= ti [1 ] <= ihigh ]
993985
994986 # so that we don't lose ticks on the end, expand out the interval ever
995987 # so slightly. The "ever so slightly" is defined to be the width of a
0 commit comments