You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yesterday i asked if there was a way to avoid scientific notation when charting (#165), so i thought i would share my solution.
There are three ways to go:
Scale your dataframe data to a magnitude that doesn't require scientific notation, there is a good example made by @DanielGoldfarb on how to do this on the issue i linked.
A similar solution to option 2) that doesn't require using your own formatter:
Here is how i did it:
fig, axlist = mpf.plot(df, returnfig=True) # MAKE SURE TO SET returnfig=True. IF YOU ARE SAVING THE CHART USING savefig, REMOVE IT, THE CHART WILL BE SAVED LATER
ax1 = axlist[0]
ax1.yaxis.set_major_formatter(FormatStrFormatter('%.8f'))
#If you want to save the chart
fig.savefig('mychart.png') #Saving the chart
Here is how i did it. The problem with this solution:
It works well with the candlestick chart, but for some reason the Volume subplot will still use scientific notation. I don't know if that's an error with my code or if it's because they are two different charts, but in case anyone knew how to fix that aswell or add to this, it's welcome.
The prices are rendered without scientific notation, which is what we wanted!
The volume is still rendered with scientific notation
I created this issue to share my own solution as well as to try to improve it and make it work with the volume chart. I think it can be useful to anyone who would like to do the same with a fairly simple fix.
The text was updated successfully, but these errors were encountered:
The volume subplot will be in axlist[1] or axlist[2] (i forget which, would have to check the code). Or you could just try looping for ax in axlist: and reformat them all.
Yes indeed, formatting them using a loop worked!
Here is how i did it:
for ax in axlist:
ax.yaxis.set_major_formatter(FormatStrFormatter('%.8f'))
So, you can avoid scientific notation on a single subplot by selecting its index from the axlist list, or it can be avoided on all the subplots at once by using a loop, like i did.
Thanks @DanielGoldfarb ! I hope this will be useful for other devs too!
Yesterday i asked if there was a way to avoid scientific notation when charting (#165), so i thought i would share my solution.
There are three ways to go:
Scale your dataframe data to a magnitude that doesn't require scientific notation, there is a good example made by @DanielGoldfarb on how to do this on the issue i linked.
Use the followig solution
A similar solution to option 2) that doesn't require using your own formatter:
Here is how i did it:
Here is how i did it.
The problem with this solution:
It works well with the candlestick chart, but for some reason the Volume subplot will still use scientific notation. I don't know if that's an error with my code or if it's because they are two different charts, but in case anyone knew how to fix that aswell or add to this, it's welcome.
I created this issue to share my own solution as well as to try to improve it and make it work with the volume chart. I think it can be useful to anyone who would like to do the same with a fairly simple fix.
The text was updated successfully, but these errors were encountered: