-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logarithmic scale #138
Comments
presently no. this will be worked on in the near future (see #21), perhaps as early as a few a weeks from now. in the meantime, you may try the |
Here is how I do it from decimal import Decimal
import mplfinance as mpf
import matplotlib.ticker as ticker
def format_price(x, _=None):
x = Decimal(x)
return x.quantize(Decimal(1)) if x == x.to_integral() else x.normalize()
fig, axlist = mpf.plot(ohlc, ..., returnfig=True)
ax1 = axlist[0]
ax1_minor_yticks = ax1.get_yticks(True) # save the original ticks because the log ticks are sparse
ax1_major_yticks = ax1.get_yticks(False)
ax1.set_yscale('log')
ax1.set_yticks(ax1_major_yticks, True)
ax1.set_yticks(ax1_minor_yticks, False)
ax1.yaxis.set_major_formatter(ticker.FuncFormatter(format_price))
ax1.yaxis.set_minor_formatter(ticker.FuncFormatter(format_price)) |
Thank you Daniel. |
thanks char101. i don't know why but i get this error: |
Check your version number: If necessary, The most up to date release is version 0.12.4a0 |
You'll need to modify the major ticks not the minor ticks. Your 2nd chart only shows minor ticks and no major ticks while the grid is rendered at major ticks positions. |
Thanks. |
is it possible to set y axis (price) scale to logarithmic scale?
The text was updated successfully, but these errors were encountered: