30
30
"facecolor" : ["facecolors" , "fc" ],
31
31
"linestyle" : ["linestyles" , "dashes" , "ls" ],
32
32
"linewidth" : ["linewidths" , "lw" ],
33
+ "offset_transform" : ["transOffset" ],
33
34
})
34
35
class Collection (artist .Artist , cm .ScalarMappable ):
35
36
r"""
@@ -84,7 +85,7 @@ def __init__(self,
84
85
joinstyle = None ,
85
86
antialiaseds = None ,
86
87
offsets = None ,
87
- transOffset = None ,
88
+ offset_transform = None ,
88
89
norm = None , # optional for ScalarMappable
89
90
cmap = None , # ditto
90
91
pickradius = 5.0 ,
@@ -127,7 +128,7 @@ def __init__(self,
127
128
A vector by which to translate each patch after rendering (default
128
129
is no translation). The translation is performed in screen (pixel)
129
130
coordinates (i.e. after the Artist's transform is applied).
130
- transOffset : `~.transforms .Transform`, default: `.IdentityTransform`
131
+ offset_transform : `~.Transform`, default: `.IdentityTransform`
131
132
A single transform which will be applied to each *offsets* vector
132
133
before it is used.
133
134
norm : `~.colors.Normalize`, optional
@@ -202,7 +203,7 @@ def __init__(self,
202
203
offsets = offsets [None , :]
203
204
self ._offsets = offsets
204
205
205
- self ._transOffset = transOffset
206
+ self ._offset_trf = offset_transform
206
207
207
208
self ._path_effects = None
208
209
self .update (kwargs )
@@ -219,22 +220,23 @@ def get_transforms(self):
219
220
220
221
def get_offset_transform (self ):
221
222
"""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_trf is None :
224
+ self ._offset_trf = transforms .IdentityTransform ()
225
+ elif (not isinstance (self ._offset_trf , transforms .Transform )
226
+ and hasattr (self ._offset_trf , '_as_mpl_transform' )):
227
+ self ._offset_trf = self ._offset_trf ._as_mpl_transform (self .axes )
228
+ return self ._offset_trf
228
229
229
- def set_offset_transform (self , transOffset ):
230
+ @_api .rename_parameter ("3.6" , "transOffset" , "offset_transform" )
231
+ def set_offset_transform (self , offset_transform ):
230
232
"""
231
233
Set the artist offset transform.
232
234
233
235
Parameters
234
236
----------
235
- transOffset : `.Transform`
237
+ offset_transform : `.Transform`
236
238
"""
237
- self ._transOffset = transOffset
239
+ self ._offset_trf = offset_transform
238
240
239
241
def get_datalim (self , transData ):
240
242
# Calculate the data limits and return them as a `.Bbox`.
@@ -254,9 +256,9 @@ def get_datalim(self, transData):
254
256
# 3. otherwise return a null Bbox.
255
257
256
258
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 ):
259
+ offset_trf = self .get_offset_transform ()
260
+ has_offsets = np .any (self ._offsets ) # True if any non-zero offsets
261
+ if has_offsets and not offset_trf .contains_branch (transData ):
260
262
# if there are offsets but in some coords other than data,
261
263
# then don't use them for autoscaling.
262
264
return transforms .Bbox .null ()
@@ -284,16 +286,16 @@ def get_datalim(self, transData):
284
286
return mpath .get_path_collection_extents (
285
287
transform .get_affine () - transData , paths ,
286
288
self .get_transforms (),
287
- transOffset .transform_non_affine (offsets ),
288
- transOffset .get_affine ().frozen ())
289
- if hasOffsets :
289
+ offset_trf .transform_non_affine (offsets ),
290
+ offset_trf .get_affine ().frozen ())
291
+ if has_offsets :
290
292
# this is for collections that have their paths (shapes)
291
293
# in physical, axes-relative, or figure-relative units
292
294
# (i.e. like scatter). We can't uniquely set limits based on
293
295
# those shapes, so we just set the limits based on their
294
296
# location.
295
297
296
- offsets = (transOffset - transData ).transform (offsets )
298
+ offsets = (offset_trf - transData ).transform (offsets )
297
299
# note A-B means A B^{-1}
298
300
offsets = np .ma .masked_invalid (offsets )
299
301
if not offsets .mask .all ():
@@ -311,7 +313,7 @@ def _prepare_points(self):
311
313
# Helper for drawing and hit testing.
312
314
313
315
transform = self .get_transform ()
314
- transOffset = self .get_offset_transform ()
316
+ offset_trf = self .get_offset_transform ()
315
317
offsets = self ._offsets
316
318
paths = self .get_paths ()
317
319
@@ -332,17 +334,17 @@ def _prepare_points(self):
332
334
paths = [transform .transform_path_non_affine (path )
333
335
for path in paths ]
334
336
transform = transform .get_affine ()
335
- if not transOffset .is_affine :
336
- offsets = transOffset .transform_non_affine (offsets )
337
+ if not offset_trf .is_affine :
338
+ offsets = offset_trf .transform_non_affine (offsets )
337
339
# This might have changed an ndarray into a masked array.
338
- transOffset = transOffset .get_affine ()
340
+ offset_trf = offset_trf .get_affine ()
339
341
340
342
if isinstance (offsets , np .ma .MaskedArray ):
341
343
offsets = offsets .filled (np .nan )
342
344
# Changing from a masked array to nan-filled ndarray
343
345
# is probably most efficient at this point.
344
346
345
- return transform , transOffset , offsets , paths
347
+ return transform , offset_trf , offsets , paths
346
348
347
349
@artist .allow_rasterization
348
350
def draw (self , renderer ):
@@ -352,7 +354,7 @@ def draw(self, renderer):
352
354
353
355
self .update_scalarmappable ()
354
356
355
- transform , transOffset , offsets , paths = self ._prepare_points ()
357
+ transform , offset_trf , offsets , paths = self ._prepare_points ()
356
358
357
359
gc = renderer .new_gc ()
358
360
self ._set_gc_clip (gc )
@@ -408,11 +410,11 @@ def draw(self, renderer):
408
410
gc .set_url (self ._urls [0 ])
409
411
renderer .draw_markers (
410
412
gc , paths [0 ], combined_transform .frozen (),
411
- mpath .Path (offsets ), transOffset , tuple (facecolors [0 ]))
413
+ mpath .Path (offsets ), offset_trf , tuple (facecolors [0 ]))
412
414
else :
413
415
renderer .draw_path_collection (
414
416
gc , transform .frozen (), paths ,
415
- self .get_transforms (), offsets , transOffset ,
417
+ self .get_transforms (), offsets , offset_trf ,
416
418
self .get_facecolor (), self .get_edgecolor (),
417
419
self ._linewidths , self ._linestyles ,
418
420
self ._antialiaseds , self ._urls ,
@@ -459,7 +461,7 @@ def contains(self, mouseevent):
459
461
if self .axes :
460
462
self .axes ._unstale_viewLim ()
461
463
462
- transform , transOffset , offsets , paths = self ._prepare_points ()
464
+ transform , offset_trf , offsets , paths = self ._prepare_points ()
463
465
464
466
# Tests if the point is contained on one of the polygons formed
465
467
# by the control points of each of the paths. A point is considered
@@ -469,7 +471,7 @@ def contains(self, mouseevent):
469
471
ind = _path .point_in_path_collection (
470
472
mouseevent .x , mouseevent .y , pickradius ,
471
473
transform .frozen (), paths , self .get_transforms (),
472
- offsets , transOffset , pickradius <= 0 )
474
+ offsets , offset_trf , pickradius <= 0 )
473
475
474
476
return len (ind ) > 0 , dict (ind = ind )
475
477
@@ -1317,7 +1319,7 @@ def __init__(self,
1317
1319
edgecolors=("black",),
1318
1320
linewidths=(1,),
1319
1321
offsets=offsets,
1320
- transOffset =ax.transData,
1322
+ offset_transform =ax.transData,
1321
1323
)
1322
1324
"""
1323
1325
super ().__init__ (** kwargs )
@@ -2149,7 +2151,7 @@ def draw(self, renderer):
2149
2151
return
2150
2152
renderer .open_group (self .__class__ .__name__ , self .get_gid ())
2151
2153
transform = self .get_transform ()
2152
- transOffset = self .get_offset_transform ()
2154
+ offset_trf = self .get_offset_transform ()
2153
2155
offsets = self ._offsets
2154
2156
2155
2157
if self .have_units ():
@@ -2168,9 +2170,9 @@ def draw(self, renderer):
2168
2170
else :
2169
2171
coordinates = self ._coordinates
2170
2172
2171
- if not transOffset .is_affine :
2172
- offsets = transOffset .transform_non_affine (offsets )
2173
- transOffset = transOffset .get_affine ()
2173
+ if not offset_trf .is_affine :
2174
+ offsets = offset_trf .transform_non_affine (offsets )
2175
+ offset_trf = offset_trf .get_affine ()
2174
2176
2175
2177
gc = renderer .new_gc ()
2176
2178
gc .set_snap (self .get_snap ())
@@ -2185,7 +2187,7 @@ def draw(self, renderer):
2185
2187
renderer .draw_quad_mesh (
2186
2188
gc , transform .frozen (),
2187
2189
coordinates .shape [1 ] - 1 , coordinates .shape [0 ] - 1 ,
2188
- coordinates , offsets , transOffset ,
2190
+ coordinates , offsets , offset_trf ,
2189
2191
# Backends expect flattened rgba arrays (n*m, 4) for fc and ec
2190
2192
self .get_facecolor ().reshape ((- 1 , 4 )),
2191
2193
self ._antialiased , self .get_edgecolors ().reshape ((- 1 , 4 )))
0 commit comments