I have a data set in the form of:
data = [('name1','value1','factor1')...[('nameN','valueN','factorN')]
I am trying to plot values as y (x is just the index of that y in data). I want matPlotLib to print the corresponding name and factor of the value on which the mouse pointer hovers. I found one example of that implemented but it used wxPython and unfortunately I can't use that. Any way to do that ( including if name can be shown in the toolbar of matplotlib or just appear as a label on the point and disappear upon moving away of the pointer) would be very helpful.
https://mpld3.github.io/examples/scatter_tooltip.html
import matplotlib.pyplot as plt
import numpy as np
import mpld3
fig, ax = plt.subplots(subplot_kw=dict(axisbg='#EEEEEE'))
N = 100
scatter = ax.scatter(np.random.normal(size=N),
np.random.normal(size=N),
c=np.random.random(size=N),
s=1000 * np.random.random(size=N),
alpha=0.3,
cmap=plt.cm.jet)
ax.grid(color='white', linestyle='solid')
ax.set_title("Scatter Plot (with tooltips!)", size=20)
labels = ['point {0}'.format(i + 1) for i in range(N)]
tooltip = mpld3.plugins.PointLabelTooltip(scatter, labels=labels)
mpld3.plugins.connect(fig, tooltip)
mpld3.show()
I hope its useful
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.