mplfinance
mplfinance copied to clipboard
How to get more date labels?
The existing library is sparse on placing date labels at the bottom of the charts - is there a way to customize how many show up and/or the frequency of the date labels.
There is nothing yet built into mplfinance to do this.
You can get access to matplotlib Axes objects (either via returnfig=True
, or via external axes and from there you have access to methods such as set_xticks and tick locators, etc.
@PowerrNuller This worked for me, just adjust your base and offset as needed
fig, ax = mpf.plot( df_slice, **kwargs, addplot=ichi_lines ); # matplotlib figure
xtick = 1; # each timestamp of dataframe on x axis
ytick = round(last/100, 2); # 1% price ticks on y axis
ax[0].xaxis.set_major_locator(ticker.IndexLocator(base=xtick, offset=0) );
ax[0].yaxis.set_major_locator(ticker.IndexLocator(base=ytick, offset=0) );
if ( ( bar_lngth == 15 ) or (bar_lngth == 30) ) :
fig.suptitle(sym + ' ' + str(bar_lngth) + 'min');
elif(( bar_lngth == 60 ) or (bar_lngth == 120) or (bar_lngth == 240) ) :
fig.suptitle(sym + ' ' + str(int(bar_lngth/60)) + 'hr');
plt.show();