import matplotlib as mpl
mpl.use('pgf')
pgf_with_pdflatex = {'pgf.texsystem': 'pdflatex', 'pgf.preamble': [
    '\\usepackage[author={me}]{pdfcomment}']}
mpl.rcParams.update(pgf_with_pdflatex)
import matplotlib.pyplot as plt
plt.figure(figsize=(4.5, 2.5))
plt.plot(list(range(5)))
for i in range(5):
    plt.text(i, i, '\\pdftooltip{o}{(%d,%d)}' % (i, i))
plt.savefig('tooltips.pdf')
Create pdf with tooltips in python