I have a dataframe df with 2 columns I want to plot together and days as index:
| col1 | col2 | col3 | ...
2020-01-01 | 1 | 300000 | ...
2020-01-02 | 1000 | 600000 | ...
2020-01-03 | 3000 | 50000 | ...
Plotting col1 + col2 via
df[["col1", "col2"]].plot()
shows values from 0 till 1.0 and at the top "1e6" like in this example: https://i.sstatic.net/tJjgX.png
I want the full value range on the y-axis and no scientific notation. How can I do this via pandas .plot() or matplotlib?
You have several options:
Option One: With Matplotlib
axes=fig.add_axes([0,0,1,1])
axes.set_xticks() # with list or range() inside
axes.set_yticks() # with list or range() inside
#You can also label the ticks with your desired values
axes.set_xticklabels() # with list or range() inside
axes.set_yticklabels() # with list or range() inside
Option Two: Change Pandas settings
pd.set_option('display.float_format', lambda x: '%.3f' % x)
or
pd.options.display.float_format = '{:.2f}'.format
I believe option one is better since you need it only for the graph and don't necessarily want to modify your dataframe columns.
Cheers!