![](/img/trans.png)
[英]matplotlib.pyplot.errorbar is throwing an error it shouldn't?
[英]skip the first error of a matplotlib errorbar
當嘗試使用plot使用 matplotlib 並跳過第一個錯誤時,我遇到了一些困難。 我想要的是 plot 一個錯誤欄,但跳過 plot 的第一個值。
所以我嘗試改編一個 matplotlib 示例如下:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
x = np.arange(10)
y = 2.5 * np.sin(x / 20 * np.pi)
yerr = np.linspace(0.05, 0.2, 10)
plt.errorbar(x, y + 3, yerr=yerr, label='both limits (default)')
lim = [False]+[True]*9
plt.errorbar(x, y + 1, yerr=yerr, uplims=lim, lolims=lim,
label='only last 9 values with error visualized')
plt.legend(loc='lower right')
所以我嘗試使用uplims
和lowlims
並在以后擺脫箭頭提示。 當我將上限和下限設置為False
時發生的情況是繪制了正常錯誤而不是沒有繪制。 想要的output和我的做法如下圖所示:
我知道錯誤欄的errorevery
參數,但由於我只想跳過第一個錯誤,我認為它不適用於我的問題。
某種解決方法可能是首先將 plot 與值的正常行刪除,然后刪除第一個條目和 plot 剩余值的錯誤欄。 請問有沒有更好的辦法解決這個問題?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.