/ / matplotlibの小数点以下の桁数を増やすpandas python 2.7 - python-2.7、pandas、matplotlib

matplotlibの小数点以下の桁数を増やすpandas python 2.7 - python-2.7、pandas、matplotlib

私はmatplotlibを使ってプロットしたい小数点以下6桁のパンダデータフレームを持っています:

980  1.088760
981  1.088770
982  1.088770
983  1.088740
984  1.088740

ここに画像の説明を入力

どのように私はそれを6つの場所に増加させることができますか?

回答:

回答№1は1

あなたは、 matplotlib.ticker.StrMethodFormatter 必要な有効桁数でラベルをフォーマットします。たとえば有効数字6桁、使用

matplotlib.ticker.StrMethodFormatter("{x:.6f}")

完全な例:

import numpy as np; np.random.seed(3)
import matplotlib.pyplot as plt
import matplotlib.ticker

x = np.linspace(500,900, num=201)
y = np.cumsum(np.random.normal(loc=0,scale=1e-4,size=len(x) ))+1.0888
fig, ax=plt.subplots()
ax.plot(x,y)
ax.yaxis.set_major_formatter(matplotlib.ticker.StrMethodFormatter("{x:.6f}"))

plt.show()

ここに画像の説明を入力