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_transform = offset_transform
206
207
207
208
self ._path_effects = None
208
209
self .update (kwargs )
@@ -219,22 +220,24 @@ 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_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
228
230
229
- def set_offset_transform (self , transOffset ):
231
+ @_api .rename_parameter ("3.6" , "transOffset" , "offset_transform" )
232
+ def set_offset_transform (self , offset_transform ):
230
233
"""
231
234
Set the artist offset transform.
232
235
233
236
Parameters
234
237
----------
235
- transOffset : `.Transform`
238
+ offset_transform : `.Transform`
236
239
"""
237
- self ._transOffset = transOffset
240
+ self ._offset_transform = offset_transform
238
241
239
242
def get_datalim (self , transData ):
240
243
# Calculate the data limits and return them as a `.Bbox`.
@@ -254,9 +257,9 @@ def get_datalim(self, transData):
254
257
# 3. otherwise return a null Bbox.
255
258
256
259
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 ):
260
263
# if there are offsets but in some coords other than data,
261
264
# then don't use them for autoscaling.
262
265
return transforms .Bbox .null ()
@@ -284,16 +287,16 @@ def get_datalim(self, transData):
284
287
return mpath .get_path_collection_extents (
285
288
transform .get_affine () - transData , paths ,
286
289
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 :
290
293
# this is for collections that have their paths (shapes)
291
294
# in physical, axes-relative, or figure-relative units
292
295
# (i.e. like scatter). We can't uniquely set limits based on
293
296
# those shapes, so we just set the limits based on their
294
297
# location.
295
298
296
- offsets = (transOffset - transData ).transform (offsets )
299
+ offsets = (offset_trf - transData ).transform (offsets )
297
300
# note A-B means A B^{-1}
298
301
offsets = np .ma .masked_invalid (offsets )
299
302
if not offsets .mask .all ():
@@ -311,7 +314,7 @@ def _prepare_points(self):
311
314
# Helper for drawing and hit testing.
312
315
313
316
transform = self .get_transform ()
314
- transOffset = self .get_offset_transform ()
317
+ offset_trf = self .get_offset_transform ()
315
318
offsets = self ._offsets
316
319
paths = self .get_paths ()
317
320
@@ -332,17 +335,17 @@ def _prepare_points(self):
332
335
paths = [transform .transform_path_non_affine (path )
333
336
for path in paths ]
334
337
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 )
337
340
# This might have changed an ndarray into a masked array.
338
- transOffset = transOffset .get_affine ()
341
+ offset_trf = offset_trf .get_affine ()
339
342
340
343
if isinstance (offsets , np .ma .MaskedArray ):
341
344
offsets = offsets .filled (np .nan )
342
345
# Changing from a masked array to nan-filled ndarray
343
346
# is probably most efficient at this point.
344
347
345
- return transform , transOffset , offsets , paths
348
+ return transform , offset_trf , offsets , paths
346
349
347
350
@artist .allow_rasterization
348
351
def draw (self , renderer ):
@@ -352,7 +355,7 @@ def draw(self, renderer):
352
355
353
356
self .update_scalarmappable ()
354
357
355
- transform , transOffset , offsets , paths = self ._prepare_points ()
358
+ transform , offset_trf , offsets , paths = self ._prepare_points ()
356
359
357
360
gc = renderer .new_gc ()
358
361
self ._set_gc_clip (gc )
@@ -408,11 +411,11 @@ def draw(self, renderer):
408
411
gc .set_url (self ._urls [0 ])
409
412
renderer .draw_markers (
410
413
gc , paths [0 ], combined_transform .frozen (),
411
- mpath .Path (offsets ), transOffset , tuple (facecolors [0 ]))
414
+ mpath .Path (offsets ), offset_trf , tuple (facecolors [0 ]))
412
415
else :
413
416
renderer .draw_path_collection (
414
417
gc , transform .frozen (), paths ,
415
- self .get_transforms (), offsets , transOffset ,
418
+ self .get_transforms (), offsets , offset_trf ,
416
419
self .get_facecolor (), self .get_edgecolor (),
417
420
self ._linewidths , self ._linestyles ,
418
421
self ._antialiaseds , self ._urls ,
@@ -459,7 +462,7 @@ def contains(self, mouseevent):
459
462
if self .axes :
460
463
self .axes ._unstale_viewLim ()
461
464
462
- transform , transOffset , offsets , paths = self ._prepare_points ()
465
+ transform , offset_trf , offsets , paths = self ._prepare_points ()
463
466
464
467
# Tests if the point is contained on one of the polygons formed
465
468
# by the control points of each of the paths. A point is considered
@@ -469,7 +472,7 @@ def contains(self, mouseevent):
469
472
ind = _path .point_in_path_collection (
470
473
mouseevent .x , mouseevent .y , pickradius ,
471
474
transform .frozen (), paths , self .get_transforms (),
472
- offsets , transOffset , pickradius <= 0 )
475
+ offsets , offset_trf , pickradius <= 0 )
473
476
474
477
return len (ind ) > 0 , dict (ind = ind )
475
478
@@ -1317,7 +1320,7 @@ def __init__(self,
1317
1320
edgecolors=("black",),
1318
1321
linewidths=(1,),
1319
1322
offsets=offsets,
1320
- transOffset =ax.transData,
1323
+ offset_transform =ax.transData,
1321
1324
)
1322
1325
"""
1323
1326
super ().__init__ (** kwargs )
@@ -2150,7 +2153,7 @@ def draw(self, renderer):
2150
2153
return
2151
2154
renderer .open_group (self .__class__ .__name__ , self .get_gid ())
2152
2155
transform = self .get_transform ()
2153
- transOffset = self .get_offset_transform ()
2156
+ offset_trf = self .get_offset_transform ()
2154
2157
offsets = self ._offsets
2155
2158
2156
2159
if self .have_units ():
@@ -2169,9 +2172,9 @@ def draw(self, renderer):
2169
2172
else :
2170
2173
coordinates = self ._coordinates
2171
2174
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 ()
2175
2178
2176
2179
gc = renderer .new_gc ()
2177
2180
gc .set_snap (self .get_snap ())
@@ -2186,7 +2189,7 @@ def draw(self, renderer):
2186
2189
renderer .draw_quad_mesh (
2187
2190
gc , transform .frozen (),
2188
2191
coordinates .shape [1 ] - 1 , coordinates .shape [0 ] - 1 ,
2189
- coordinates , offsets , transOffset ,
2192
+ coordinates , offsets , offset_trf ,
2190
2193
# Backends expect flattened rgba arrays (n*m, 4) for fc and ec
2191
2194
self .get_facecolor ().reshape ((- 1 , 4 )),
2192
2195
self ._antialiased , self .get_edgecolors ().reshape ((- 1 , 4 )))
0 commit comments