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

set_url() without effect in the plot for instances of Tick #9695

Copy link
Copy link
Closed
@khyox

Description

@khyox
Issue body actions

Bug report

Bug summary

Using SVG back-end, setting the url attribute in objects of class Tick does nothing regarding the final plot, whereas it does for other objects.

Code for reproduction

It is an extension of the hyperlinks example to
to deal with hyperlinks in the ticks:

import matplotlib as mpl
mpl.use('SVG')
import matplotlib.pyplot as plt

f = plt.figure()
ax = f.gca()
s = plt.scatter([1, 2, 3], [4, 5, 6])
s.set_urls(['http://www.bbc.co.uk/news', 'http://www.google.com', None])
for tick, pos, label in ax.yaxis.iter_ticks():
    tick.set_url('http://www.python.org')
    print(tick.get_url(), pos, label)
f.savefig('scatter.svg')

Actual outcome

I get:

http://www.python.org 3.75 3.75
http://www.python.org 4.0 4.00
http://www.python.org 4.25 4.25
.....
http://www.python.org 6.25 6.25

So it properly changes the url attribute. Unfortunately, the svg file generated has no trace of the ticks hyperlinks:

> grep python scatter.svg
>

...while it does for the scatter plot links, for instance:

 > egrep google scatter.svg
    <a xlink:href="http://www.google.com">

Expected outcome

> egrep python scatter.svg
      <a xlink:href="http://www.python.org">
      <a xlink:href="http://www.python.org">
.....
      <a xlink:href="http://www.python.org">

Matplotlib version

  • Operating system:
  • Matplotlib version: current dev ('2.1.0.post658.dev0+g39694f2)
  • Matplotlib backend: SVG
  • Python version: 3.6.3

Posible cause and suggested solution
I traced the problem to the Trick class, where the url attribute is not passed to any of the objects that are to be drawn. My successful workaround has been to override the set_url() method in the class Tick to transfer the url attribute content to the tick labels, that are to be drawn. I'll prepare a PR with this simple solution to be evaluated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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