@@ -107,7 +107,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
107107 def draw_path_collection (self , master_transform , cliprect , clippath ,
108108 clippath_trans , paths , all_transforms , offsets ,
109109 offsetTrans , facecolors , edgecolors , linewidths ,
110- linestyles , antialiaseds ):
110+ linestyles , antialiaseds , urls ):
111111 """
112112 Draws a collection of paths, selecting drawing properties from
113113 the lists *facecolors*, *edgecolors*, *linewidths*,
@@ -136,7 +136,7 @@ def draw_path_collection(self, master_transform, cliprect, clippath,
136136 for xo , yo , path_id , gc , rgbFace in self ._iter_collection (
137137 path_ids , cliprect , clippath , clippath_trans ,
138138 offsets , offsetTrans , facecolors , edgecolors ,
139- linewidths , linestyles , antialiaseds ):
139+ linewidths , linestyles , antialiaseds , urls ):
140140 path , transform = path_id
141141 transform = transforms .Affine2D (transform .get_matrix ()).translate (xo , yo )
142142 self .draw_path (gc , path , transform , rgbFace )
@@ -164,7 +164,7 @@ def draw_quad_mesh(self, master_transform, cliprect, clippath,
164164 return self .draw_path_collection (
165165 master_transform , cliprect , clippath , clippath_trans ,
166166 paths , [], offsets , offsetTrans , facecolors , edgecolors ,
167- linewidths , [], [antialiased ])
167+ linewidths , [], [antialiased ], [ None ] )
168168
169169 def _iter_collection_raw_paths (self , master_transform , paths , all_transforms ):
170170 """
@@ -198,7 +198,7 @@ def _iter_collection_raw_paths(self, master_transform, paths, all_transforms):
198198
199199 def _iter_collection (self , path_ids , cliprect , clippath , clippath_trans ,
200200 offsets , offsetTrans , facecolors , edgecolors ,
201- linewidths , linestyles , antialiaseds ):
201+ linewidths , linestyles , antialiaseds , urls ):
202202 """
203203 This is a helper method (along with
204204 :meth:`_iter_collection_raw_paths`) to make it easier to write
@@ -232,6 +232,7 @@ def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans,
232232 Nlinewidths = len (linewidths )
233233 Nlinestyles = len (linestyles )
234234 Naa = len (antialiaseds )
235+ Nurls = len (urls )
235236
236237 if (Nfacecolors == 0 and Nedgecolors == 0 ) or Npaths == 0 :
237238 return
@@ -268,6 +269,9 @@ def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans,
268269 gc .set_alpha (rgbFace [- 1 ])
269270 rgbFace = rgbFace [:3 ]
270271 gc .set_antialiased (antialiaseds [i % Naa ])
272+
273+ if Nurls :
274+ gc .set_url (urls [i % Nurls ])
271275
272276 yield xo , yo , path_id , gc , rgbFace
273277
@@ -433,6 +437,7 @@ def __init__(self):
433437 self ._linewidth = 1
434438 self ._rgb = (0.0 , 0.0 , 0.0 )
435439 self ._hatch = None
440+ self ._url = None
436441
437442 def copy_properties (self , gc ):
438443 'Copy properties from gc to self'
@@ -447,6 +452,7 @@ def copy_properties(self, gc):
447452 self ._linewidth = gc ._linewidth
448453 self ._rgb = gc ._rgb
449454 self ._hatch = gc ._hatch
455+ self ._url = gc ._url
450456
451457 def get_alpha (self ):
452458 """
@@ -521,6 +527,12 @@ def get_rgb(self):
521527 matlab format string, a html hex color string, or a rgb tuple
522528 """
523529 return self ._rgb
530+
531+ def get_url (self ):
532+ """
533+ returns a url if one is set, None otherwise
534+ """
535+ return self ._url
524536
525537 def set_alpha (self , alpha ):
526538 """
@@ -621,6 +633,12 @@ def set_linestyle(self, style):
621633 raise ValueError ('Unrecognized linestyle: %s' % style )
622634 self ._linestyle = style
623635 self .set_dashes (offset , dashes )
636+
637+ def set_url (self , url ):
638+ """
639+ Sets the url for links in compatible backends
640+ """
641+ self ._url = url
624642
625643 def set_hatch (self , hatch ):
626644 """
0 commit comments