Skip to content

set_url without effect for instances of Line2D #17336

Description

@dloeckx

Bug report

Bug summary
Using SVG-backend, set_url does nothing for for instances of Line2D, whereas it works for other objects.

Code for reproduction

from matplotlib import pyplot as plt

f = plt.figure()
s = plt.scatter([1, 2, 3], [4, 5, 6])
s.set_urls(['http://www.bbc.co.uk/news', 'http://www.google.com', None])
p = plt.plot([1,3], [6,5], linewidth=5, color='green')
p[0].set_url('http://www.duckduckgo.com')

print(s.get_urls())
print(p[0].get_url())

import io
svg = io.StringIO()
f.savefig(svg, format='svg')

assert "http://www.google.com" in svg.getvalue()
assert "http://www.duckduckgo.com" in svg.getvalue()

Actual outcome

['http://www.bbc.co.uk/news', 'http://www.google.com', None]
http://www.duckduckgo.com
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-5-830e26be00ec> in <module>
     15 
     16 assert "http://www.google.com" in svg.getvalue()
---> 17 assert "http://www.duckduckgo.com" in svg.getvalue()

When the svg is opened in a browser, the scatter plot is clickable yet the line is not.

Expected outcome

Both http://www.google.com and http://www.duckduckgo.com should be present in the svg. When the svg is opened in a browser, the line plot should be clickable as well.

Matplotlib version

  • Operating system: Ubuntu 18.04.3 LTS
  • Matplotlib version: 3.2.1
  • Matplotlib backend: module://ipykernel.pylab.backend_inline
  • Python version: 3.7.6 (conda)
  • Jupyter version (if applicable): 1.2.4
  • Other libraries:

I installed matplotlb and python over conda. Issue remains if I install matplotlib from pip, and run the script from the command line.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions