root
root copied to clipboard
Enable embedding hyperlinks in TLegend
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