3030 "facecolor" : ["facecolors" , "fc" ],
3131 "linestyle" : ["linestyles" , "dashes" , "ls" ],
3232 "linewidth" : ["linewidths" , "lw" ],
33+ "offset_transform" : ["transOffset" ],
3334})
3435class Collection (artist .Artist , cm .ScalarMappable ):
3536 r"""
@@ -84,7 +85,7 @@ def __init__(self,
8485 joinstyle = None ,
8586 antialiaseds = None ,
8687 offsets = None ,
87- transOffset = None ,
88+ offset_transform = None ,
8889 norm = None , # optional for ScalarMappable
8990 cmap = None , # ditto
9091 pickradius = 5.0 ,
@@ -127,7 +128,7 @@ def __init__(self,
127128 A vector by which to translate each patch after rendering (default
128129 is no translation). The translation is performed in screen (pixel)
129130 coordinates (i.e. after the Artist's transform is applied).
130- transOffset : `~.transforms .Transform`, default: `.IdentityTransform`
131+ offset_transform : `~.Transform`, default: `.IdentityTransform`
131132 A single transform which will be applied to each *offsets* vector
132133 before it is used.
133134 norm : `~.colors.Normalize`, optional
@@ -202,7 +203,7 @@ def __init__(self,
202203 offsets = offsets [None , :]
203204 self ._offsets = offsets
204205
205- self ._transOffset = transOffset
206+ self ._offset_transform = offset_transform
206207
207208 self ._path_effects = None
208209 self .update (kwargs )
@@ -219,22 +220,24 @@ def get_transforms(self):
219220
220221 def get_offset_transform (self ):
221222 """Return the `.Transform` instance used by this artist offset."""
222- if self ._transOffset is None :
223- self ._transOffset = transforms .IdentityTransform ()
224- elif (not isinstance (self ._transOffset , transforms .Transform )
225- and hasattr (self ._transOffset , '_as_mpl_transform' )):
226- self ._transOffset = self ._transOffset ._as_mpl_transform (self .axes )
227- return self ._transOffset
223+ if self ._offset_transform is None :
224+ self ._offset_transform = transforms .IdentityTransform ()
225+ elif (not isinstance (self ._offset_transform , transforms .Transform )
226+ and hasattr (self ._offset_transform , '_as_mpl_transform' )):
227+ self ._offset_transform = \
228+ self ._offset_transform ._as_mpl_transform (self .axes )
229+ return self ._offset_transform
228230
229- def set_offset_transform (self , transOffset ):
231+ @_api .rename_parameter ("3.6" , "transOffset" , "offset_transform" )
232+ def set_offset_transform (self , offset_transform ):
230233 """
231234 Set the artist offset transform.
232235
233236 Parameters
234237 ----------
235- transOffset : `.Transform`
238+ offset_transform : `.Transform`
236239 """
237- self ._transOffset = transOffset
240+ self ._offset_transform = offset_transform
238241
239242 def get_datalim (self , transData ):
240243 # Calculate the data limits and return them as a `.Bbox`.
@@ -254,9 +257,9 @@ def get_datalim(self, transData):
254257 # 3. otherwise return a null Bbox.
255258
256259 transform = self .get_transform ()
257- transOffset = self .get_offset_transform ()
258- hasOffsets = np .any (self ._offsets ) # True if any non-zero offsets
259- if hasOffsets and not transOffset .contains_branch (transData ):
260+ 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 ):
260263 # if there are offsets but in some coords other than data,
261264 # then don't use them for autoscaling.
262265 return transforms .Bbox .null ()
@@ -284,16 +287,16 @@ def get_datalim(self, transData):
284287 return mpath .get_path_collection_extents (
285288 transform .get_affine () - transData , paths ,
286289 self .get_transforms (),
287- transOffset .transform_non_affine (offsets ),
288- transOffset .get_affine ().frozen ())
289- if hasOffsets :
290+ offset_trf .transform_non_affine (offsets ),
291+ offset_trf .get_affine ().frozen ())
292+ if has_offsets :
290293 # this is for collections that have their paths (shapes)
291294 # in physical, axes-relative, or figure-relative units
292295 # (i.e. like scatter). We can't uniquely set limits based on
293296 # those shapes, so we just set the limits based on their
294297 # location.
295298
296- offsets = (transOffset - transData ).transform (offsets )
299+ offsets = (offset_trf - transData ).transform (offsets )
297300 # note A-B means A B^{-1}
298301 offsets = np .ma .masked_invalid (offsets )
299302 if not offsets .mask .all ():
@@ -311,7 +314,7 @@ def _prepare_points(self):
311314 # Helper for drawing and hit testing.
312315
313316 transform = self .get_transform ()
314- transOffset = self .get_offset_transform ()
317+ offset_trf = self .get_offset_transform ()
315318 offsets = self ._offsets
316319 paths = self .get_paths ()
317320
@@ -332,17 +335,17 @@ def _prepare_points(self):
332335 paths = [transform .transform_path_non_affine (path )
333336 for path in paths ]
334337 transform = transform .get_affine ()
335- if not transOffset .is_affine :
336- offsets = transOffset .transform_non_affine (offsets )
338+ if not offset_trf .is_affine :
339+ offsets = offset_trf .transform_non_affine (offsets )
337340 # This might have changed an ndarray into a masked array.
338- transOffset = transOffset .get_affine ()
341+ offset_trf = offset_trf .get_affine ()
339342
340343 if isinstance (offsets , np .ma .MaskedArray ):
341344 offsets = offsets .filled (np .nan )
342345 # Changing from a masked array to nan-filled ndarray
343346 # is probably most efficient at this point.
344347
345- return transform , transOffset , offsets , paths
348+ return transform , offset_trf , offsets , paths
346349
347350 @artist .allow_rasterization
348351 def draw (self , renderer ):
@@ -352,7 +355,7 @@ def draw(self, renderer):
352355
353356 self .update_scalarmappable ()
354357
355- transform , transOffset , offsets , paths = self ._prepare_points ()
358+ transform , offset_trf , offsets , paths = self ._prepare_points ()
356359
357360 gc = renderer .new_gc ()
358361 self ._set_gc_clip (gc )
@@ -408,11 +411,11 @@ def draw(self, renderer):
408411 gc .set_url (self ._urls [0 ])
409412 renderer .draw_markers (
410413 gc , paths [0 ], combined_transform .frozen (),
411- mpath .Path (offsets ), transOffset , tuple (facecolors [0 ]))
414+ mpath .Path (offsets ), offset_trf , tuple (facecolors [0 ]))
412415 else :
413416 renderer .draw_path_collection (
414417 gc , transform .frozen (), paths ,
415- self .get_transforms (), offsets , transOffset ,
418+ self .get_transforms (), offsets , offset_trf ,
416419 self .get_facecolor (), self .get_edgecolor (),
417420 self ._linewidths , self ._linestyles ,
418421 self ._antialiaseds , self ._urls ,
@@ -459,7 +462,7 @@ def contains(self, mouseevent):
459462 if self .axes :
460463 self .axes ._unstale_viewLim ()
461464
462- transform , transOffset , offsets , paths = self ._prepare_points ()
465+ transform , offset_trf , offsets , paths = self ._prepare_points ()
463466
464467 # Tests if the point is contained on one of the polygons formed
465468 # by the control points of each of the paths. A point is considered
@@ -469,7 +472,7 @@ def contains(self, mouseevent):
469472 ind = _path .point_in_path_collection (
470473 mouseevent .x , mouseevent .y , pickradius ,
471474 transform .frozen (), paths , self .get_transforms (),
472- offsets , transOffset , pickradius <= 0 )
475+ offsets , offset_trf , pickradius <= 0 )
473476
474477 return len (ind ) > 0 , dict (ind = ind )
475478
@@ -1317,7 +1320,7 @@ def __init__(self,
13171320 edgecolors=("black",),
13181321 linewidths=(1,),
13191322 offsets=offsets,
1320- transOffset =ax.transData,
1323+ offset_transform =ax.transData,
13211324 )
13221325 """
13231326 super ().__init__ (** kwargs )
@@ -2150,7 +2153,7 @@ def draw(self, renderer):
21502153 return
21512154 renderer .open_group (self .__class__ .__name__ , self .get_gid ())
21522155 transform = self .get_transform ()
2153- transOffset = self .get_offset_transform ()
2156+ offset_trf = self .get_offset_transform ()
21542157 offsets = self ._offsets
21552158
21562159 if self .have_units ():
@@ -2169,9 +2172,9 @@ def draw(self, renderer):
21692172 else :
21702173 coordinates = self ._coordinates
21712174
2172- if not transOffset .is_affine :
2173- offsets = transOffset .transform_non_affine (offsets )
2174- transOffset = transOffset .get_affine ()
2175+ if not offset_trf .is_affine :
2176+ offsets = offset_trf .transform_non_affine (offsets )
2177+ offset_trf = offset_trf .get_affine ()
21752178
21762179 gc = renderer .new_gc ()
21772180 gc .set_snap (self .get_snap ())
@@ -2186,7 +2189,7 @@ def draw(self, renderer):
21862189 renderer .draw_quad_mesh (
21872190 gc , transform .frozen (),
21882191 coordinates .shape [1 ] - 1 , coordinates .shape [0 ] - 1 ,
2189- coordinates , offsets , transOffset ,
2192+ coordinates , offsets , offset_trf ,
21902193 # Backends expect flattened rgba arrays (n*m, 4) for fc and ec
21912194 self .get_facecolor ().reshape ((- 1 , 4 )),
21922195 self ._antialiased , self .get_edgecolors ().reshape ((- 1 , 4 )))
0 commit comments