@@ -1028,62 +1028,29 @@ def _update_ticks(self, renderer):
1028
1028
ihigh = locs [- 1 ]
1029
1029
tick_tups = [ti for ti in tick_tups if ilow <= ti [1 ] <= ihigh ]
1030
1030
1031
- # so that we don't lose ticks on the end, expand out the interval ever
1032
- # so slightly. The "ever so slightly" is defined to be the width of a
1033
- # half of a pixel. We don't want to draw a tick that even one pixel
1034
- # outside of the defined axis interval.
1035
- if interval [0 ] <= interval [1 ]:
1036
- interval_expanded = interval
1037
- else :
1038
- interval_expanded = interval [1 ], interval [0 ]
1039
-
1040
- if hasattr (self , '_get_pixel_distance_along_axis' ):
1041
- # normally, one does not want to catch all exceptions that
1042
- # could possibly happen, but it is not clear exactly what
1043
- # exceptions might arise from a user's projection (their
1044
- # rendition of the Axis object). So, we catch all, with
1045
- # the idea that one would rather potentially lose a tick
1046
- # from one side of the axis or another, rather than see a
1047
- # stack trace.
1048
- # We also catch users warnings here. These are the result of
1049
- # invalid numpy calculations that may be the result of out of
1050
- # bounds on axis with finite allowed intervals such as geo
1051
- # projections i.e. Mollweide.
1052
- with np .errstate (invalid = 'ignore' ):
1053
- try :
1054
- ds1 = self ._get_pixel_distance_along_axis (
1055
- interval_expanded [0 ], - 0.5 )
1056
- except Exception :
1057
- cbook ._warn_external ("Unable to find pixel distance "
1058
- "along axis for interval padding of "
1059
- "ticks; assuming no interval "
1060
- "padding needed." )
1061
- ds1 = 0.0
1062
- if np .isnan (ds1 ):
1063
- ds1 = 0.0
1064
- try :
1065
- ds2 = self ._get_pixel_distance_along_axis (
1066
- interval_expanded [1 ], + 0.5 )
1067
- except Exception :
1068
- cbook ._warn_external ("Unable to find pixel distance "
1069
- "along axis for interval padding of "
1070
- "ticks; assuming no interval "
1071
- "padding needed." )
1072
- ds2 = 0.0
1073
- if np .isnan (ds2 ):
1074
- ds2 = 0.0
1075
- interval_expanded = (interval_expanded [0 ] - ds1 ,
1076
- interval_expanded [1 ] + ds2 )
1031
+ if interval [1 ] <= interval [0 ]:
1032
+ interval = interval [1 ], interval [0 ]
1033
+ inter = self .get_transform ().transform (interval )
1077
1034
1078
1035
ticks_to_draw = []
1079
1036
for tick , loc , label in tick_tups :
1037
+ # draw each tick if it is in interval. Note the transform
1038
+ # to pixel space to take care of log transforms etc.
1039
+ # interval_contains has a floating point tolerance.
1080
1040
if tick is None :
1081
1041
continue
1082
1042
# NB: always update labels and position to avoid issues like #9397
1083
1043
tick .update_position (loc )
1084
1044
tick .set_label1 (label )
1085
1045
tick .set_label2 (label )
1086
- if not mtransforms .interval_contains (interval_expanded , loc ):
1046
+ try :
1047
+ loct = self .get_transform ().transform (loc )
1048
+ except AssertionError :
1049
+ # transforms.transform doesn't allow masked values but
1050
+ # some scales might make them, so we need this try/except.
1051
+ loct = None
1052
+ continue
1053
+ if not mtransforms .interval_contains_close (inter , loct ):
1087
1054
continue
1088
1055
ticks_to_draw .append (tick )
1089
1056
0 commit comments