mplfinance
mplfinance copied to clipboard
Add `xlabel=` kwarg to `mpf.plot()`
Has anyone figured out a way to add the word 'date' to the x-axis title along with the actual dates displayed.
I want it to basically be the same as the y-axis, with the word 'Price' displayed and the prices, but with the date in the x-axis.
It seems like a simple addition, but I can't seem to figure it out.
I have included a photo to show what I would like to achieve, but want to label 'Date' to be displayed lower below the actual dates.
mpf.plot()
has a ylabel
kwarg to set the label on the y-axis, but it does not have an xlabel
kwarg to set the xlabel.
If you would like to contribute an xlabel=
kwarg enhancement, I would be happy to guide you through the process. It is a relatively simple enhancement (perfect for "getting your feet wet" if you have never contributed to an Open Source project before).
In the meantime, as a workaround for your own plots, you can use the returnfig
kwarg, and set the xlabel yourself, for example:
fig, axlist = mpf.plot(df,returnfig=True)
axlist[-2].set_xlabel('Date')
mpf.show()
Notice the index on axlist
must be -2
to ensure you are setting the label on the primary axes of the bottom panel.
(For more information about axlist
see item number 1 under Accessing mplfinance Figure and Axes objects).
Please consider contributing the xlabel
enhancement to mplfinance. Let me know if you are interested. Thank you.