mplfinance
mplfinance copied to clipboard
Tooltip feature in mplfinance
How can I add tooltip feature in mplfinance candlestick plot? I have provided the drive link that contains code and output. https://drive.google.com/file/d/1y6EX2dIYiLsn4nByG7vuXbmK6yWyyYWC/view
Tooltips are not directly supported in mplfinance, however this should be possible by setting returnfig=True
when calling mpf.plot()
to gain access to the Figure and Axes objects, and then using matplotlib to set up the annotations.
For some examples see:
- https://matplotlib.org/3.1.0/gallery/user_interfaces/svg_tooltip_sgskip.html
- https://stackoverflow.com/questions/7908636/possible-to-make-labels-appear-when-hovering-over-a-point-in-matplotlib
- and/or google "hover annotations matplotlib" or "tooltips matplotlib".
If you get it working I would like to see the code.
I would like to incorporate this feature into mplfinance to make it easy for users to do.
All the best. --Daniel
Is it possible to integrate libraries such as MPLD for tooltip? https://mpld3.github.io/examples/scatter_tooltip.html
I think tooltips, rangesliders should be good features to add. In Plotly, we can add rangesliders to candlestick chart and have tooltips as well, but indicator plotting for example is very difficult.
@sarangab
Thank you for contributing to the disussion. I was looking at that exact page earlier today. Of course, anything can be integrated. However as a general rule I am reluctant to add depednecies to mplfinance. (Also, while I have never used mpld3, if my understanding is correct it works specifically with browser and notebook matplotlib backend interfaces, but not with other matplotlib backend interfaces such as X-windows; but correct me if I am wrong. If I'm correct about that, then I would be even more reluctant to add such a dependency since it would be useful only in certain environments.) All this is not etched in stone, just my strong inclination, from which I could be persuaded, if given a compeling argument for adding dependencies.
In general, I would be more inclined to provide an interface that makes it easier for the two libraries to work together.
Presently you should be able to user matplotlib's annotations and hover event feature, or a third party library such as mpld3, by gaining access to mplfinance's Figure and Axes objects.