@@ -1051,60 +1051,28 @@ def _update_ticks(self, renderer):
1051
1051
ihigh = locs [- 1 ]
1052
1052
tick_tups = [ti for ti in tick_tups if ilow <= ti [1 ] <= ihigh ]
1053
1053
1054
- # so that we don't lose ticks on the end, expand out the interval ever
1055
- # so slightly. The "ever so slightly" is defined to be the width of a
1056
- # half of a pixel. We don't want to draw a tick that even one pixel
1057
- # outside of the defined axis interval.
1058
- if interval [0 ] <= interval [1 ]:
1059
- interval_expanded = interval
1060
- else :
1061
- interval_expanded = interval [1 ], interval [0 ]
1062
-
1063
- if hasattr (self , '_get_pixel_distance_along_axis' ):
1064
- # normally, one does not want to catch all exceptions that
1065
- # could possibly happen, but it is not clear exactly what
1066
- # exceptions might arise from a user's projection (their
1067
- # rendition of the Axis object). So, we catch all, with
1068
- # the idea that one would rather potentially lose a tick
1069
- # from one side of the axis or another, rather than see a
1070
- # stack trace.
1071
- # We also catch users warnings here. These are the result of
1072
- # invalid numpy calculations that may be the result of out of
1073
- # bounds on axis with finite allowed intervals such as geo
1074
- # projections i.e. Mollweide.
1075
- with np .errstate (invalid = 'ignore' ):
1076
- try :
1077
- ds1 = self ._get_pixel_distance_along_axis (
1078
- interval_expanded [0 ], - 0.5 )
1079
- except Exception :
1080
- warnings .warn ("Unable to find pixel distance along axis "
1081
- "for interval padding of ticks; assuming no "
1082
- "interval padding needed." )
1083
- ds1 = 0.0
1084
- if np .isnan (ds1 ):
1085
- ds1 = 0.0
1086
- try :
1087
- ds2 = self ._get_pixel_distance_along_axis (
1088
- interval_expanded [1 ], + 0.5 )
1089
- except Exception :
1090
- warnings .warn ("Unable to find pixel distance along axis "
1091
- "for interval padding of ticks; assuming no "
1092
- "interval padding needed." )
1093
- ds2 = 0.0
1094
- if np .isnan (ds2 ):
1095
- ds2 = 0.0
1096
- interval_expanded = (interval_expanded [0 ] - ds1 ,
1097
- interval_expanded [1 ] + ds2 )
1054
+ if interval [1 ] <= interval [0 ]:
1055
+ interval = interval [1 ], interval [0 ]
1056
+ inter = self .get_transform ().transform (interval )
1098
1057
1099
1058
ticks_to_draw = []
1100
1059
for tick , loc , label in tick_tups :
1060
+ # draw each tick if it is in interval. Note the transform
1061
+ # to pixel space to take care of log transforms etc.
1062
+ # interval_contains has a floating point tolerance.
1101
1063
if tick is None :
1102
1064
continue
1103
1065
# NB: always update labels and position to avoid issues like #9397
1104
1066
tick .update_position (loc )
1105
1067
tick .set_label1 (label )
1106
1068
tick .set_label2 (label )
1107
- if not mtransforms .interval_contains (interval_expanded , loc ):
1069
+ try :
1070
+ loct = self .get_transform ().transform (loc )
1071
+ except AssertionError :
1072
+ loct = None
1073
+ continue
1074
+ if ((loct is None ) or
1075
+ (not mtransforms .interval_contains (inter , loct ))):
1108
1076
continue
1109
1077
ticks_to_draw .append (tick )
1110
1078
0 commit comments