@@ -258,9 +258,9 @@ def get_datalim(self, transData):
258258
259259 transform = self .get_transform ()
260260 offset_trf = self .get_offset_transform ()
261- has_offsets = np . any ( self . _offsets ) # True if any non-zero offsets
262- if has_offsets and not offset_trf .contains_branch (transData ):
263- # if there are offsets but in some coords other than data,
261+ if not ( isinstance ( offset_trf , transforms . IdentityTransform )
262+ or offset_trf .contains_branch (transData ) ):
263+ # if the offsets are in some coords other than data,
264264 # then don't use them for autoscaling.
265265 return transforms .Bbox .null ()
266266 offsets = self ._offsets
@@ -289,20 +289,19 @@ def get_datalim(self, transData):
289289 self .get_transforms (),
290290 offset_trf .transform_non_affine (offsets ),
291291 offset_trf .get_affine ().frozen ())
292- if has_offsets :
293- # this is for collections that have their paths (shapes)
294- # in physical, axes-relative, or figure-relative units
295- # (i.e. like scatter). We can't uniquely set limits based on
296- # those shapes, so we just set the limits based on their
297- # location.
298-
299- offsets = (offset_trf - transData ).transform (offsets )
300- # note A-B means A B^{-1}
301- offsets = np .ma .masked_invalid (offsets )
302- if not offsets .mask .all ():
303- bbox = transforms .Bbox .null ()
304- bbox .update_from_data_xy (offsets )
305- return bbox
292+
293+ # this is for collections that have their paths (shapes)
294+ # in physical, axes-relative, or figure-relative units
295+ # (i.e. like scatter). We can't uniquely set limits based on
296+ # those shapes, so we just set the limits based on their
297+ # location.
298+ offsets = (offset_trf - transData ).transform (offsets )
299+ # note A-B means A B^{-1}
300+ offsets = np .ma .masked_invalid (offsets )
301+ if not offsets .mask .all ():
302+ bbox = transforms .Bbox .null ()
303+ bbox .update_from_data_xy (offsets )
304+ return bbox
306305 return transforms .Bbox .null ()
307306
308307 def get_window_extent (self , renderer ):
0 commit comments