在 matplotlib 中設定誤差線中顯示範圍分圖


為了在 matplotlib 中設定顯示範圍分圖或誤差線,我們可以採取以下步驟 -

  • 設定圖形大小並調整子圖之間的和周圍的填充。
  • 使用 numpy 建立 x 和 y 資料點。
  • 建立圖形和一組子圖。
  • 以帶有附加誤差線的線和/或標記的形式繪製 y 與 x。
  • 要顯示圖形,請使用 show() 方法。

示例

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = np.arange(0.1, 4, 0.5)
y = np.exp(-x)

fig, ax = plt.subplots()
ax.errorbar(x, y, xerr=0.2, yerr=0.4)

plt.show()

輸出

更新於:2021-08-03

99 次瀏覽

開啟你的職業生涯

透過完成課程獲得認證

開始學習
Advertisement
© . All rights reserved.