@@ -46,6 +46,7 @@ class Collection(artist.Artist, cm.ScalarMappable):
46
46
:class:`matplotlib.cm.ScalarMappable`)
47
47
* *cmap*: None (optional for
48
48
:class:`matplotlib.cm.ScalarMappable`)
49
+ * *hatch*: None
49
50
50
51
*offsets* and *transOffset* are used to translate the patch after
51
52
rendering (default no offsets).
@@ -77,6 +78,7 @@ def __init__(self,
77
78
norm = None , # optional for ScalarMappable
78
79
cmap = None , # ditto
79
80
pickradius = 5.0 ,
81
+ hatch = None ,
80
82
urls = None ,
81
83
** kwargs
82
84
):
@@ -95,6 +97,7 @@ def __init__(self,
95
97
self .set_antialiased (antialiaseds )
96
98
self .set_pickradius (pickradius )
97
99
self .set_urls (urls )
100
+ self .set_hatch (hatch )
98
101
99
102
100
103
self ._uniform_offsets = None
@@ -232,7 +235,10 @@ def draw(self, renderer):
232
235
gc = renderer .new_gc ()
233
236
self ._set_gc_clip (gc )
234
237
gc .set_snap (self .get_snap ())
235
-
238
+
239
+ if self ._hatch :
240
+ gc .set_hatch (self ._hatch )
241
+
236
242
renderer .draw_path_collection (
237
243
gc , transform .frozen (), paths , self .get_transforms (),
238
244
offsets , transOffset , self .get_facecolor (), self .get_edgecolor (),
@@ -292,6 +298,38 @@ def set_urls(self, urls):
292
298
293
299
def get_urls (self ): return self ._urls
294
300
301
+ def set_hatch (self , hatch ):
302
+ """
303
+ Set the hatching pattern
304
+
305
+ *hatch* can be one of::
306
+
307
+ / - diagonal hatching
308
+ \ - back diagonal
309
+ | - vertical
310
+ - - horizontal
311
+ + - crossed
312
+ x - crossed diagonal
313
+ o - small circle
314
+ O - large circle
315
+ . - dots
316
+ * - stars
317
+
318
+ Letters can be combined, in which case all the specified
319
+ hatchings are done. If same letter repeats, it increases the
320
+ density of hatching of that pattern.
321
+
322
+ Hatching is supported in the PostScript, PDF, SVG and Agg
323
+ backends only.
324
+
325
+ ACCEPTS: [ '/' | '\\ \\ ' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
326
+ """
327
+ self ._hatch = hatch
328
+
329
+ def get_hatch (self ):
330
+ 'Return the current hatching pattern'
331
+ return self ._hatch
332
+
295
333
def set_offsets (self , offsets ):
296
334
"""
297
335
Set the offsets for the collection. *offsets* can be a scalar
0 commit comments