Home > OS >  How to change y axis format to float or its sensitivity ? (Pandas plot)
How to change y axis format to float or its sensitivity ? (Pandas plot)

Time:03-19

Data;

anahtar_tarih
2017-12-31    99.7131646900
2018-01-15    99.7032566000
2018-01-31    99.7043161400
2018-02-15    99.6793628400
2018-02-28    99.6793627900
                  ...      
2021-12-15    99.9166534100
2021-12-31    99.9166573800
2022-01-15    99.9346317600
2022-01-31    99.9342393100
2022-02-15    99.9605692600
Name: rate, Length: 108, dtype: object

Here is my basic code;

df.rate.astype(int).plot(figsize=(10, 10))
plt.suptitle('Rate Graphic')
plt.show()

The plot is like following; plot

Normally sensitivity much bigger than the plot itself, how can i increase the sensitivity on y axis?

For ex it shows 99.8 but i want to show it with more than 1 number after dot. Because my dataset is like ; 99.7131646900 etc.

How can i do that? Thanks,

CodePudding user response:

You can use StrMethodFormatter:

from matplotlib.ticker import StrMethodFormatter

df.rate.astype(int).plot(figsize=(10, 10))

plt.gca().yaxis.set_major_formatter(StrMethodFormatter('{x:,.2f}')) # 2 decimal places
plt.show()
  • Related