mplfinance
mplfinance copied to clipboard
ylim step size
how can i change the ylim to have a step size of 2?
John,
ylim
controls the limits of the y-axis values (minimum and maximum). I believe you want to change the y-axis tick positions (not ylim). In your plot the major ticks are placed every 5 from 1910 to 1950. Can you confirm if that is what you are looking to do, that is setting ticks positions (not y-limits)?
Yes, setting tick positions is what I'm looking to do.
Currently working on an enhancement to allow you to modify the y-axis tick positions in mpf.plot()
. It may be some time until complete, however in the meantime, as a workaround you can manually modify the ticks as follows:
Add returnfig=True
to your call to mpf.plot()
, and then set the y-ticks on the Axes object returned:
ylimits=(1908,1950)
yticks = [ yt for yt in range( ylimits[0], ylimits[-1], 2) ]
fig, axlist = mpf.plot(nq2006_04, style=s, show_nontrading=True, xrotation=0, ylim=ylimits,returnfig=True)
axlist[0].set_yticks(yticks)
mpf.show()
Currently working on an enhancement to allow you to modify the y-axis tick positions in
mpf.plot()
. It may be some time until complete, however in the meantime, as a workaround you can manually modify the ticks as follows:Add
returnfig=True
to your call tompf.plot()
, and then set the y-ticks on the Axes object returned:ylimits=(1908,1950) yticks = [ yt for yt in range( ylimits[0], ylimits[-1], 2) ] fig, axlist = mpf.plot(nq2006_04, style=s, show_nontrading=True, xrotation=0, ylim=ylimits,returnfig=True) axlist[0].set_yticks(yticks) mpf.show()
Hi Daniel,
Is this workaround still needed, or did you already implement "modify the y-axis tick positions in mpf.plot()" ?.