@@ -208,7 +208,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path,
208
208
def draw_path_collection (self , gc , master_transform , paths , all_transforms ,
209
209
offsets , offset_trans , facecolors , edgecolors ,
210
210
linewidths , linestyles , antialiaseds , urls ,
211
- offset_position ):
211
+ offset_position , hatchcolors = None ):
212
212
"""
213
213
Draw a collection of *paths*.
214
214
@@ -217,8 +217,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
217
217
*master_transform*. They are then translated by the corresponding
218
218
entry in *offsets*, which has been first transformed by *offset_trans*.
219
219
220
- *facecolors*, *edgecolors*, *linewidths*, *linestyles*, and
221
- *antialiased * are lists that set the corresponding properties.
220
+ *facecolors*, *edgecolors*, *linewidths*, *linestyles*, *antialiased*
221
+ and *hatchcolors * are lists that set the corresponding properties.
222
222
223
223
*offset_position* is unused now, but the argument is kept for
224
224
backwards compatibility.
@@ -235,10 +235,13 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
235
235
path_ids = self ._iter_collection_raw_paths (master_transform ,
236
236
paths , all_transforms )
237
237
238
+ if hatchcolors is None :
239
+ hatchcolors = []
240
+
238
241
for xo , yo , path_id , gc0 , rgbFace in self ._iter_collection (
239
242
gc , list (path_ids ), offsets , offset_trans ,
240
243
facecolors , edgecolors , linewidths , linestyles ,
241
- antialiaseds , urls , offset_position ):
244
+ antialiaseds , urls , offset_position , hatchcolors ):
242
245
path , transform = path_id
243
246
# Only apply another translation if we have an offset, else we
244
247
# reuse the initial transform.
@@ -252,7 +255,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
252
255
253
256
def draw_quad_mesh (self , gc , master_transform , meshWidth , meshHeight ,
254
257
coordinates , offsets , offsetTrans , facecolors ,
255
- antialiased , edgecolors ):
258
+ antialiased , edgecolors , hatchcolors = None ):
256
259
"""
257
260
Draw a quadmesh.
258
261
@@ -265,11 +268,13 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
265
268
266
269
if edgecolors is None :
267
270
edgecolors = facecolors
271
+ if hatchcolors is None :
272
+ hatchcolors = []
268
273
linewidths = np .array ([gc .get_linewidth ()], float )
269
274
270
275
return self .draw_path_collection (
271
276
gc , master_transform , paths , [], offsets , offsetTrans , facecolors ,
272
- edgecolors , linewidths , [], [antialiased ], [None ], 'screen' )
277
+ edgecolors , linewidths , [], [antialiased ], [None ], 'screen' , hatchcolors )
273
278
274
279
def draw_gouraud_triangles (self , gc , triangles_array , colors_array ,
275
280
transform ):
@@ -337,7 +342,7 @@ def _iter_collection_uses_per_path(self, paths, all_transforms,
337
342
338
343
def _iter_collection (self , gc , path_ids , offsets , offset_trans , facecolors ,
339
344
edgecolors , linewidths , linestyles ,
340
- antialiaseds , urls , offset_position ):
345
+ antialiaseds , urls , offset_position , hatchcolors = None ):
341
346
"""
342
347
Helper method (along with `_iter_collection_raw_paths`) to implement
343
348
`draw_path_collection` in a memory-efficient manner.
@@ -360,16 +365,20 @@ def _iter_collection(self, gc, path_ids, offsets, offset_trans, facecolors,
360
365
*path_ids*; *gc* is a graphics context and *rgbFace* is a color to
361
366
use for filling the path.
362
367
"""
368
+ if hatchcolors is None :
369
+ hatchcolors = []
370
+
363
371
Npaths = len (path_ids )
364
372
Noffsets = len (offsets )
365
373
N = max (Npaths , Noffsets )
366
374
Nfacecolors = len (facecolors )
367
375
Nedgecolors = len (edgecolors )
376
+ Nhatchcolors = len (hatchcolors )
368
377
Nlinewidths = len (linewidths )
369
378
Nlinestyles = len (linestyles )
370
379
Nurls = len (urls )
371
380
372
- if (Nfacecolors == 0 and Nedgecolors == 0 ) or Npaths == 0 :
381
+ if (Nfacecolors == 0 and Nedgecolors == 0 and Nhatchcolors == 0 ) or Npaths == 0 :
373
382
return
374
383
375
384
gc0 = self .new_gc ()
@@ -384,6 +393,7 @@ def cycle_or_default(seq, default=None):
384
393
toffsets = cycle_or_default (offset_trans .transform (offsets ), (0 , 0 ))
385
394
fcs = cycle_or_default (facecolors )
386
395
ecs = cycle_or_default (edgecolors )
396
+ hcs = cycle_or_default (hatchcolors )
387
397
lws = cycle_or_default (linewidths )
388
398
lss = cycle_or_default (linestyles )
389
399
aas = cycle_or_default (antialiaseds )
@@ -392,8 +402,8 @@ def cycle_or_default(seq, default=None):
392
402
if Nedgecolors == 0 :
393
403
gc0 .set_linewidth (0.0 )
394
404
395
- for pathid , (xo , yo ), fc , ec , lw , ls , aa , url in itertools .islice (
396
- zip (pathids , toffsets , fcs , ecs , lws , lss , aas , urls ), N ):
405
+ for pathid , (xo , yo ), fc , ec , hc , lw , ls , aa , url in itertools .islice (
406
+ zip (pathids , toffsets , fcs , ecs , hcs , lws , lss , aas , urls ), N ):
397
407
if not (np .isfinite (xo ) and np .isfinite (yo )):
398
408
continue
399
409
if Nedgecolors :
@@ -405,6 +415,8 @@ def cycle_or_default(seq, default=None):
405
415
gc0 .set_linewidth (0 )
406
416
else :
407
417
gc0 .set_foreground (ec )
418
+ if Nhatchcolors :
419
+ gc0 .set_hatch_color (hc )
408
420
if fc is not None and len (fc ) == 4 and fc [3 ] == 0 :
409
421
fc = None
410
422
gc0 .set_antialiased (aa )
0 commit comments