Hi. im very new in coding, so sorry for being naive.
i have written some codes which puts out decent results:
import matplotlib
matplotlib.rcParams['backend'] = "Qt5Agg"
import matplotlib.pyplot as plt
import pandas_datareader.data as web
import datetime
import mplfinance as mpf
start = datetime.datetime(2016, 3, 1)
end = datetime.datetime(2017, 3, 1)
skhynix = web.DataReader("000660.KS", "yahoo", start, end)
mpf.plot(skhynix, type='candle', volume=True, show_nontrading=True, style='yahoo')
i know 1 year(start, end) is too long for any major analysis so if i fix the code to this,
mpf.plot(skhynix[200:], type='candle', volume=True, show_nontrading=True, style='yahoo', datetime-format = '%d' )
i get some shorter results.
in this case the chart shows the dates in the x axis, but they are too far apart (3, 13, 23, ...)
i want the chart to have a x axis that shows all the dates, (1, 2, 3, 4, 5, 8, 9, 10 ...)
how can i do that?
i have a old book about python that explains this, but it uses the old mpl finance, which im trying to avoid.
(i know u can access this with old_flavor or something)
but im not sure how to apply this to the new mplfinance.
PS >>> is there a way to have titles in your figures?(like up in the top or besides the axes)
i figured out the title part..
@skfnxh
Let me answer your second question first, because it is simpler. You can add a title to the Figure or to a subplot using the title or the axtitle kwargs. You can place a label (title) the beside the y-axis using ylabel kwarg. Mplfinance does not provide direct access to the x-axis label because it is always time/date, however if you want to label it you can do so by gaining access to the Axes objects created by mplfinance and calling the appropriate matplotlib function.
That said, the fact that you would ask such a questions suggests that you have not taken the time to go through the mplfinance tutorials. I strongly suggest you set aside time to go through the first 4 tutorials; it should take no more than 15 to 20 minutes at most and will be time well spent:
Regarding your initial question, customizing the x-axis ticks and/or the interval between them: we are presently working on an enhancement to support this in a general and easy way. It will likely be a few more weeks until it is ready for release. In the meantime, you can implement your own workaround by gaining access to the Axes object(s) created by mplfinance and then calling .xaxis.set_major_locator() on the Axes object. The code might look something like this:
import matplotlib.ticker as ticker
fig, axlist = mpf.plot(df,type='candle',returnfig=True)
axlist[0].xaxis.set_major_locator(ticker.MultipleLocator(1))
mpf.show()
See also https://github.com/matplotlib/mplfinance/issues/247
HTH. All the best. --Daniel
@DanielGoldfarb
Thanks a bunch!
I will definitely check out the tutorials, i was just so focused on this axis thingies. (although i have nothing to do with them, yet)
Even though i really don't know anything about codes and such, i think mplfinance is something amazing for sure..
Thanks again for this package!