Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable embedding hyperlinks in TLegend #16512

Open
vepadulano opened this issue Sep 23, 2024 · 1 comment
Open

Enable embedding hyperlinks in TLegend #16512

vepadulano opened this issue Sep 23, 2024 · 1 comment
Assignees

Comments

@vepadulano
Copy link
Member

Explain what you would like to see improved and how.

I have a simple snippet which produces a plot (in PDF or SVG) where the text items in the legend are clickable hyperlinks:

from matplotlib import pyplot as plt
plt.rcParams['svg.fonttype'] = 'none'
fig = plt.figure()
plt.scatter([1], [2], label="CERN")
plt.scatter([1], [2.25], label="ROOT")
leg = plt.legend()
for ta in leg.texts:
    t = ta.get_text()
    if t == "CERN":
        url = 'https://home.cern'
        ta.set_url(url)
    elif t == "ROOT":
        url = 'https://root.cern'
        ta.set_url(url)

fig.savefig('scatter.svg')
fig.savefig('scatter.pdf')

Can be run with python repro.py and saves both SVG and PDF files with the clickable links in the legend.

It would be nice to have the same feature also for TLegend. I have taken a look at TLink but despite what the docs hint at, that cannot be used to show hyperlinks, rather only links between different graphical components of the same canvas/browser.

ROOT version

Any

Installation method

Any

Operating system

Any

Additional context

No response

@couet
Copy link
Member

couet commented Sep 26, 2024

@vepadulano can you post the 2 files generated by your macro ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants