How can I display letters or numbers on each candle stick on mplfinance? For example, I want to show 0 (for green bars) and 1 (for red bars) on top of each candle stick, instead of marks.
Asked
Active
Viewed 726 times
1 Answers
1
There are a number of ways to do this. You can do it with Axes.text() or with Axes.annotate() as noted in these examples:
- https://stackoverflow.com/a/70342687/1639359
- https://github.com/matplotlib/mplfinance/issues/387#issuecomment-828135146
However, probably the easiest solution is to use mpf.make_addplot() to create a type=scatter plot where you want the numbers to appear, and then pass in a sequence of markers for the marker= kwarg (of make_addplot), and use Mathtext markers for the markers (for example "$1$" is a '1', etc.)
Click here for example code.
Other discussions that may be worth reading through:
Daniel Goldfarb
- 6,937
- 5
- 29
- 61