10000 Ensure URLs are stored for plain lines in SVG. · QuLogic/matplotlib@eecad37 · GitHub
[go: up one dir, main page]

Skip to content

Commit eecad37

Browse files
committed
Ensure URLs are stored for plain lines in SVG.
Fixes matplotlib#17336.
1 parent 4984505 commit eecad37

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/matplotlib/lines.py

Lines 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

Lines 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