@@ -53,6 +53,46 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
5353 """
5454 renderer .draw_path (gc , tpath , affine , rgbFace )
5555
56+ def draw_path_collection (self , renderer ,
57+ gc , master_transform , paths , all_transforms ,
58+ offsets , offsetTrans , facecolors , edgecolors ,
59+ linewidths , linestyles , antialiaseds , urls ,
60+ offset_position ):
61+ """
62+ Draws a collection of paths selecting drawing properties from
63+ the lists *facecolors*, *edgecolors*, *linewidths*,
64+ *linestyles* and *antialiaseds*. *offsets* is a list of
65+ offsets to apply to each of the paths. The offsets in
66+ *offsets* are first transformed by *offsetTrans* before being
67+ applied. *offset_position* may be either "screen" or "data"
68+ depending on the space that the offsets are in.
69+
70+ This provides a fallback implementation of
71+ :meth:`draw_path_collection` that makes multiple calls to
72+ :meth:`draw_path`. Some backends may want to override this in
73+ order to render each set of path data only once, and then
74+ reference that path multiple times with the different offsets,
75+ colors, styles etc. The generator methods
76+ :meth:`_iter_collection_raw_paths` and
77+ :meth:`_iter_collection` are provided to help with (and
78+ standardize) the implementation across backends. It is highly
79+ recommended to use those generators, so that changes to the
80+ behavior of :meth:`draw_path_collection` can be made globally.
81+ """
82+ path_ids = []
83+ for path , transform in renderer ._iter_collection_raw_paths (
84+ master_transform , paths , all_transforms ):
85+ path_ids .append ((path , transform ))
86+
87+ for xo , yo , path_id , gc0 , rgbFace in renderer ._iter_collection (
88+ gc , master_transform , all_transforms , path_ids , offsets ,
89+ offsetTrans , facecolors , edgecolors , linewidths , linestyles ,
90+ antialiaseds , urls , offset_position ):
91+ path , transform = path_id
92+ transform = transforms .Affine2D (transform .get_matrix ()).translate (xo , yo )
93+ self .draw_path (renderer , gc0 , path , transform , rgbFace )
94+
95+
5696 def draw_tex (self , renderer , gc , x , y , s , prop , angle , ismath = 'TeX!' ):
5797 self ._draw_text_as_path (renderer , gc , x , y , s , prop , angle , ismath = "TeX" )
5898
@@ -101,21 +141,6 @@ def draw_markers(self, renderer, gc, marker_path, marker_trans, path, trans, rgb
101141 marker_trans + transforms .Affine2D ().translate (x , y ),
102142 rgbFace )
103143
104- # def draw_path_collection(self, renderer,
105- # gc, master_transform, paths, all_transforms,
106- # offsets, offsetTrans, facecolors, edgecolors,
107- # linewidths, linestyles, antialiaseds, urls):
108- # path_ids = []
109- # for path, transform in renderer._iter_collection_raw_paths(
110- # master_transform, paths, all_transforms):
111- # path_ids.append((path, transform))
112-
113- # for xo, yo, path_id, gc0, rgbFace in renderer._iter_collection(
114- # gc, path_ids, offsets, offsetTrans, facecolors, edgecolors,
115- # linewidths, linestyles, antialiaseds, urls):
116- # path, transform = path_id
117- # transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo)
118- # self.draw_path(renderer, gc0, path, transform, rgbFace)
119144
120145class ProxyRenderer (object ):
121146 def __init__ (self , path_effect , renderer ):
@@ -138,6 +163,17 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
138163 gc , marker_path , marker_trans , path , trans ,
139164 rgbFace = rgbFace )
140165
166+ def draw_path_collection (self , gc , master_transform , paths , all_transforms ,
167+ offsets , offsetTrans , facecolors , edgecolors ,
168+ linewidths , linestyles , antialiaseds , urls ,
169+ offset_position ):
170+ pe = self ._path_effect
171+ pe .draw_path_collection (self ._renderer ,
172+ gc , master_transform , paths , all_transforms ,
173+ offsets , offsetTrans , facecolors , edgecolors ,
174+ linewidths , linestyles , antialiaseds , urls ,
175+ offset_position )
176+
141177
142178class Normal (_Base ):
143179 """
0 commit comments