Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08169a9

Browse filesBrowse files
committed
Ensure URLs are stored for plain lines in SVG.
Fixes #17336.
1 parent 3964f2a commit 08169a9
Copy full SHA for 08169a9

File tree

2 files changed

+10
-2
lines changed
Filter options

2 files changed

+10
-2
lines changed

‎lib/matplotlib/lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/lines.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ def draw(self, renderer):
761761
if len(tpath.vertices):
762762
gc = renderer.new_gc()
763763
self._set_gc_clip(gc)
764+
gc.set_url(self.get_url())
764765

765766
lc_rgba = mcolors.to_rgba(self._color, self._alpha)
766767
gc.set_foreground(lc_rgba, isRGBA=True)
@@ -787,6 +788,7 @@ def draw(self, renderer):
787788
if self._marker and self._markersize > 0:
788789
gc = renderer.new_gc()
789790
self._set_gc_clip(gc)
791+
gc.set_url(self.get_url())
790792
gc.set_linewidth(self._markeredgewidth)
791793
gc.set_antialiased(self._antialiased)
792794

‎lib/matplotlib/tests/test_backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_svg.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,20 @@ def test_url():
220220
# Test that object url appears in output svg.
221221

222222
fig, ax = plt.subplots()
223+
224+
# collections
223225
s = ax.scatter([1, 2, 3], [4, 5, 6])
224226
s.set_urls(['http://example.com/foo', 'http://example.com/bar', None])
225227

228+
# Line2D
229+
p, = plt.plot([1, 3], [6, 5])
230+
p.set_url('http://example.com/baz')
231+
226232
b = BytesIO()
227233
fig.savefig(b, format='svg')
228234
b = b.getvalue()
229-
assert b'http://example.com/foo' in b
230-
assert b'http://example.com/bar' in b
235+
for v in [b'foo', b'bar', b'baz']:
236+
assert b'http://example.com/' + v in b
231237

232238

233239
def test_url_tick():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.