I recently decided to code a small program in Python3 that plots the OHLC prices stored in a dataframe and also highlights a horizontal line for a specific price on said graph. For this work, the
However, I am interested in learning how someone can specify the start date from which the horizontal line in the figure above would be drawn, so that this horizontal line does not go over the entire graph but only over those values after the start date, that is, a graph like the following:
If it's not too much trouble, I would also like to know how I could add a small label to said horizontal line as shown in the image.
I appreciate anyone who can help me out.
CodePudding user response:
The mplfinance kwarg hlines
is by definition all the way from one side of the plot to the other. To plot a horizontal line that does not stretch from one side to the other, use kwarg alines
.
To add text or an annotation near the line, use axlist[0].text()
or axlist[0].annotate()