簡體   English   中英

繪制不對稱誤差線 Matplotlib

[英]Plotting asymmetric error bars Matplotlib

所以我有三組數據:

min_data = np.array([ 0.317, 0.312, 0.305, 0.296, 0.281, 0.264, 0.255, 
0.237, 0.222, 0.203, 0.186, 0.17, 0.155, 0.113, 0.08])

avg_data = np.array([ 0.3325, 0.3235, 0.3135, 0.30216667, 0.2905, 0.27433333, 
0.26116667, 0.24416667, 0.22833333, 0.20966667, 0.19366667, 0.177, 
0.16316667, 0.14016667, 0.097])

max_data = np.array([ 0.346, 0.331, 0.32, 0.31, 0.299, 0.282, 0.266, 0.25, 
0.234, 0.218, 0.204, 0.187, 0.175, 0.162, 0.115])

我需要用誤差線繪制這些數據。

我嘗試過:

x = np.linspace(0, 100, 15)
err = [min_data, max_data]
plt.errorbar(x, avg_data, 'bo', yerr=err)

TypeError: errorbar() got multiple values for argument 'yerr'

最終圖形應如下所示:

plt.plot(x[::-1], avg_data, 'ro')
plt.plot(x[::-1], min_data, 'bo')
plt.plot(x[::-1], max_data, 'bo')

在此處輸入圖片說明

藍點代表誤差線應位於的位置。

我能找到的所有文檔只允許在 + 和 - y 方向上相等的不對稱誤差。

謝謝

您的代碼失敗,因為它認為, 'bo'yerr說法,因為在第三個參數plt.errorbaryerr 如果要傳遞格式說明符,則應使用fmt關鍵字。

plt.errorbar(x, avg_data, fmt='bo', yerr=err)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM