I\'ve created a plot in Python using matplotlib. After annotating each line, I\'d like to make the label a hyperlink (or alternatively, make the line itself a hyperlink). Th
This is possible with pgf backend:
#!/usr/bin/env python3
import matplotlib
matplotlib.use("pgf")
pgf_with_custom_preamble = {
"text.usetex": True,
"pgf.preamble": [
r"\usepackage{hyperref}"
]
}
matplotlib.rcParams.update(pgf_with_custom_preamble)
from matplotlib import pyplot as plt
x = range(5)
y = range(5)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y, "r-", label=r"Hyperlink: \url{http://google.com}")
ax.legend()
fig.savefig("mwe.pdf")