[Solved] How to add separate lines to mplfinance plot?


Additional lines include a vertical line, a horizontal line, a line connecting two or more pairs of dates and prices, and a trend line. Here is an example of simply drawing a line with date and price. Please refer to this page for more details.

import datetime
import pandas as pd
import pandas_datareader.data as web
import mplfinance as mpf

import yfinance as yf
data = yf.download("AAPL", start="2021-01-01", end="2021-07-01")

two_points = [('2021-06-04', 128),('2021-06-30', 138)]
mpf.plot(data, figratio=(8,4), type="candle", alines=two_points, volume=True, mav=(5, 25), style="yahoo")

enter image description here

solved How to add separate lines to mplfinance plot?