Would it be easy to give bar charts a feature analogous to PointLabelTooltip
? Hovering over a bar would make the tooltip appear.
You can do this with the LineLabelTooltip
:
N = 10
bars = plt.bar(np.arange(N), np.random.normal(size=N))
for i, bar in enumerate(bars.get_children()):
tooltip = mpld3.plugins.LineLabelTooltip(bar, label=str(i))
mpld3.plugins.connect(plt.gcf(), tooltip)
mpld3.display()
It could be worth having a BarTooltip
plugin that makes this easier.
Thanks for the tip.
Hi Aflaxman,
I was struggling to add tooltips to the bars using PointHTMLTooltip. After replacing it by LineLabelTooltip and understanding that bars are composed by rectangle patches it worked!
Thank you very much for that...
One more question though... How can add a customizable ccs for the LineLabelTooltip plugin? I would like to format the tooltips as left arrows (.tooltip .tooltiptext::after).
In PointHTMLTooltip I can pass the css but in LineLabelTooltip this option is not available...
Thanks
Replacing LineLabelTooltip by LineHTMLTooltip and wrapping the label in tooltip html tags worked.
Like:
label="
Most helpful comment
You can do this with the
LineLabelTooltip
:It could be worth having a
BarTooltip
plugin that makes this easier.