When trying to plot an errorbar using matplotlib and skipping the first error I ran into some difficulties. What I want is to plot an errorbar but to skip the first value for the plot.
So I tried to adapt a matplotlib example as follows:
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')
So I tried to use uplims
and lowlims
and get rid of the arrow tips later. What's happening when I set the upper and lower limit to False
is that a normal error is plotted instead of none. The desired output and my approach is shown in the following figure:
I'm aware of the errorevery
parameter of the errorbar, but as I only want to skip the first error I think it's not applicable to my problem.
Some kind of workaround could be to first plot a normal line with the values, then get rid of the first entry and plot an errorbar for the remaining values. I'm asking if there's a better solution to this?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.