Mplfinance: How to get more date labels?

Created on 22 Jul 2020  路  2Comments  路  Source: matplotlib/mplfinance

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.

enhancement in progress question

Most helpful comment

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.

All 2 comments

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

image

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();

Was this page helpful?
0 / 5 - 0 ratings

Related issues

viorell91 picture viorell91  路  3Comments

ghost355 picture ghost355  路  5Comments

Full4me picture Full4me  路  3Comments

andresberejnoi picture andresberejnoi  路  6Comments

tessanix picture tessanix  路  5Comments