The MPL finance is great, however I cant seem to tweak the formatting of the axes. In the image I would like to show only the date, without the 00:00 time. Also the price, I would like to add a $ currency and decimal places (variable).
import pandas as pd
import mplfinance as mpf
df = pd.read_csv(csv)
df.date = pd.to_datetime(df.date)
cols = ['date', 'open', 'high', 'low', 'close', 'volume']
df = df[cols]
df = df.sort_values(by=['date'], ascending=False)
df = df.set_index('date')
And then calling mplfinance with (inserting style):
mpf.plot(df, type='candle', volume=True style= *style*)
Generates the below charts, I have highlight the parts I would like to change if possible.
For the date format, you can add kwarg
datetime_format
, for example:For the y-axis tick labels, I would suggest that you simply adjust the y-axis label (not the tick labels) using kwarg
ylabel='Price ($)'
or something like that.Alternatively if you really want a $ sign next to each tick label, you can do this:
Result with Default Style