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