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