如何在 Python Matplotlib 中防止數字變為指數形式?


在 ticklabel_format() 方法中使用 style='plain',我們可以禁止將值轉換為指數形式。

步驟

  • 傳遞兩個列表,使用 plot() 方法繪製一條線。

  • 對 style='plain' 使用 ticklabel_format() 方法。如果未設定引數,則不會更改格式器的相應屬性。Style='plain' 會關閉科學記號。

  • 使用 plt.show() 方法,顯示圖形。

示例

from matplotlib import pyplot as plt
plt.plot([1, 2, 3, 4, 5], [11, 12, 13, 14, 15])
plt.ticklabel_format(style='plain')    # to prevent scientific notation.
plt.show()

輸出

更新於: 2021 年 3 月 17 日

889 次瀏覽

開始你的 職業生涯

透過完成此課程進行認證

開始學習
廣告
© . All rights reserved.