@@ -54,7 +54,7 @@ class Collection(artist.Artist, cm.ScalarMappable):
54
54
_offsets = npy .array ([], npy .float_ )
55
55
_transOffset = transforms .IdentityTransform ()
56
56
_transforms = []
57
-
57
+
58
58
zorder = 1
59
59
def __init__ (self ,
60
60
edgecolors = None ,
@@ -82,7 +82,7 @@ def __init__(self,
82
82
if linewidths is None : linewidths = (mpl .rcParams ['patch.linewidth' ],)
83
83
if antialiaseds is None : antialiaseds = (mpl .rcParams ['patch.antialiased' ],)
84
84
self .set_linestyles (linestyles )
85
-
85
+
86
86
self ._facecolors = _colors .colorConverter .to_rgba_array (facecolors )
87
87
if edgecolors == 'None' :
88
88
self ._edgecolors = self ._facecolors
@@ -117,13 +117,13 @@ def _get_value(self, val):
117
117
else : return val
118
118
119
119
raise TypeError ('val must be a float or nonzero sequence of floats' )
120
-
120
+
121
121
def get_paths (self ):
122
122
raise NotImplementedError
123
123
124
124
def get_transforms (self ):
125
125
return self ._transforms
126
-
126
+
127
127
def get_datalim (self , transData ):
128
128
transform = self .get_transform ()
129
129
transOffset = self ._transOffset
@@ -136,7 +136,7 @@ def get_datalim(self, transData):
136
136
offsets = transOffset .transform_non_affine (offsets )
137
137
transOffset = transOffset .get_affine ()
138
138
offsets = npy .asarray (offsets , npy .float_ )
139
-
139
+
140
140
result = mpath .get_path_collection_extents (
141
141
transform .frozen (), paths , self .get_transforms (),
142
142
offsets , transOffset .frozen ())
@@ -163,26 +163,26 @@ def draw(self, renderer):
163
163
xs = self .convert_xunits (self ._offsets [:0 ])
164
164
ys = self .convert_yunits (self ._offsets [:1 ])
165
165
offsets = zip (xs , ys )
166
-
166
+
167
167
offsets = npy .asarray (offsets , npy .float_ )
168
168
169
169
self .update_scalarmappable ()
170
170
171
171
clippath , clippath_trans = self .get_transformed_clip_path_and_affine ()
172
172
if clippath_trans is not None :
173
173
clippath_trans = clippath_trans .frozen ()
174
-
174
+
175
175
if not transform .is_affine :
176
176
paths = [transform .transform_path_non_affine (path ) for path in paths ]
177
177
transform = transform .get_affine ()
178
178
if not transOffset .is_affine :
179
179
offsets = transOffset .transform_non_affine (offsets )
180
180
transOffset = transOffset .get_affine ()
181
-
181
+
182
182
renderer .draw_path_collection (
183
183
transform .frozen (), self .clipbox , clippath , clippath_trans ,
184
184
paths , self .get_transforms (),
185
- offsets , transOffset ,
185
+ offsets , transOffset ,
186
186
self ._facecolors , self ._edgecolors , self ._linewidths ,
187
187
self ._linestyles , self ._antialiaseds )
188
188
renderer .close_group (self .__class__ .__name__ )
@@ -210,7 +210,7 @@ def contains(self, mouseevent):
210
210
211
211
def set_pickradius (self ,pickradius ): self .pickradius = 5
212
212
def get_pickradius (self ): return self .pickradius
213
-
213
+
214
214
def set_linewidths (self , lw ):
215
215
"""
216
216
Set the linewidth(s) for the collection. lw can be a scalar or a
@@ -221,7 +221,7 @@ def set_linewidths(self, lw):
221
221
"""
222
222
self ._linewidths = self ._get_value (lw )
223
223
set_lw = set_linewidth = set_linewidths
224
-
224
+
225
225
def set_linestyles (self , ls ):
226
226
"""
227
227
Set the linestyles(s) for the collection.
@@ -251,7 +251,7 @@ def set_linestyles(self, ls):
251
251
raise ValueError ('Do not know how to convert %s to dashes' % ls )
252
252
self ._linestyles = dashes
253
253
set_dashes = set_linestyle = set_linestyles
254
-
254
+
255
255
def set_color (self , c ):
256
256
"""
257
257
Set both the edgecolor and the facecolor.
@@ -307,11 +307,11 @@ def set_alpha(self, alpha):
307
307
def get_linewidths (self ):
308
308
return self ._linewidths
309
309
get_linewidth = get_linewidths
310
-
310
+
311
311
def get_linestyles (self ):
312
312
return self ._linestyles
313
313
get_dashes = get_linestyle = get_linestyles
314
-
314
+
315
315
def update_scalarmappable (self ):
316
316
"""
317
317
If the scalar mappable array is not none, update colors
@@ -348,7 +348,7 @@ def update_scalarmappable(self):
348
348
None, they default to their patch.* rc params setting, in sequence
349
349
form.
350
350
"""
351
-
351
+
352
352
class QuadMesh (Collection ):
353
353
"""
354
354
Class for the efficient drawing of a quadrilateral mesh.
@@ -391,7 +391,7 @@ def __init__(self, meshWidth, meshHeight, coordinates, showedges, antialiased=Tr
391
391
# By converting to floats now, we can avoid that on every draw.
392
392
self ._coordinates = self ._coordinates .reshape ((meshHeight + 1 , meshWidth + 1 , 2 ))
393
393
self ._coordinates = npy .array (self ._coordinates , npy .float_ )
394
-
394
+
395
395
def get_paths (self , dataTrans = None ):
396
396
if self ._paths is None :
397
397
self ._paths = self .convert_mesh_to_paths (
@@ -401,14 +401,14 @@ def get_paths(self, dataTrans=None):
401
401
#@staticmethod
402
402
def convert_mesh_to_paths (meshWidth , meshHeight , coordinates ):
403
403
Path = mpath .Path
404
-
404
+
405
405
c = coordinates
406
406
# We could let the Path constructor generate the codes for us,
407
407
# but this is faster, since we know they'll always be the same
408
408
codes = npy .array (
409
409
[Path .MOVETO , Path .LINETO , Path .LINETO , Path .LINETO , Path .CLOSEPOLY ],
410
410
Path .code_type )
411
-
411
+
412
412
points = npy .concatenate ((
413
413
c [0 :- 1 , 0 :- 1 ],
414
414
c [0 :- 1 , 1 : ],
@@ -419,10 +419,10 @@ def convert_mesh_to_paths(meshWidth, meshHeight, coordinates):
419
419
points = points .reshape ((meshWidth * meshHeight , 5 , 2 ))
420
420
return [Path (x , codes ) for x in points ]
421
421
convert_mesh_to_paths = staticmethod (convert_mesh_to_paths )
422
-
422
+
423
423
def get_datalim (self , transData ):
424
424
return self ._bbox
425
-
425
+
426
426
def draw (self , renderer ):
427
427
if not self .get_visible (): return
428
428
renderer .open_group (self .__class__ .__name__ )
@@ -444,7 +444,7 @@ def draw(self, renderer):
444
444
clippath , clippath_trans = self .get_transformed_clip_path_and_affine ()
445
445
if clippath_trans is not None :
446
446
clippath_trans = clippath_trans .frozen ()
447
-
447
+
448
448
assert transform .is_affine
449
449
if not transOffset .is_affine :
450
450
offsets = transOffset .transform_non_affine (offsets )
@@ -478,7 +478,7 @@ def set_verts(self, verts):
478
478
479
479
def get_paths (self ):
480
480
return self ._paths
481
-
481
+
482
482
class BrokenBarHCollection (PolyCollection ):
483
483
"""
484
484
A colleciton of horizontal bars spanning yrange with a sequence of
@@ -493,13 +493,13 @@ def __init__(self, xranges, yrange, **kwargs):
493
493
"""
494
494
ymin , ywidth = yrange
495
495
ymax = ymin + ywidth
496
- verts = [ [(xmin , ymin ), (xmin , ymax ), (xmin + xwidth , ymax ), (xmin + xwidth , ymin )] for xmin , xwidth in xranges ]
496
+ verts = [ [(xmin , ymin ), (xmin , ymax ), (xmin + xwidth , ymax ), (xmin + xwidth , ymin ), ( xmin , ymin ) ] for xmin , xwidth in xranges ]
497
497
PolyCollection .__init__ (self , verts , ** kwargs )
498
498
__init__ .__doc__ = cbook .dedent (__init__ .__doc__ ) % artist .kwdocd
499
499
500
500
class RegularPolyCollection (Collection ):
501
501
_path_generator = mpath .Path .unit_regular_polygon
502
-
502
+
503
503
def __init__ (self ,
504
504
dpi ,
505
505
numsides ,
@@ -550,7 +550,7 @@ def __init__(self,
550
550
(math .sqrt (x ) * self ._dpi / 72.0 ) / math .sqrt (math .pi ))
551
551
for x in sizes ]
552
552
self .set_transform (transforms .IdentityTransform ())
553
-
553
+
554
554
__init__ .__doc__ = cbook .dedent (__init__ .__doc__ ) % artist .kwdocd
555
555
556
556
def get_paths (self ):
@@ -559,12 +559,12 @@ def get_paths(self):
559
559
560
560
class StarPolygonCollection (RegularPolyCollection ):
561
561
_path_generator = mpath .Path .unit_regular_star
562
-
563
-
562
+
563
+
564
564
class AsteriskPolygonCollection (RegularPolyCollection ):
565
565
_path_generator = mpath .Path .unit_regular_asterisk
566
-
567
-
566
+
567
+
568
568
class LineCollection (Collection , cm .ScalarMappable ):
569
569
"""
570
570
All parameters must be sequences or scalars; if scalars, they will
@@ -630,7 +630,7 @@ def __init__(self, segments, # Can be None.
630
630
self .set_linestyles (linestyles )
631
631
632
632
colors = _colors .colorConverter .to_rgba_array (colors )
633
-
633
+
634
634
Collection .__init__ (
635
635
self ,
636
636
edgecolors = colors ,
@@ -649,14 +649,14 @@ def __init__(self, segments, # Can be None.
649
649
650
650
def get_paths (self ):
651
651
return self ._paths
652
-
652
+
653
653
def set_segments (self , segments ):
654
654
if segments is None : return
655
655
segments = [npy .asarray (seg , npy .float_ ) for seg in segments ]
656
656
if self ._uniform_offsets is not None :
657
657
segments = self ._add_offsets (segments )
658
658
self ._paths = [mpath .Path (seg ) for seg in segments ]
659
-
659
+
660
660
set_verts = set_segments # for compatibility with PolyCollection
661
661
662
662
def _add_offsets (self , segs ):
0 commit comments