8000 Added ability to offset errorbars when using errorevery. by jcalbert · Pull Request #6280 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Added ability to offset errorbars when using errorevery. #6280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 28, 2019
Prev Previous commit
Next Next commit
unpacked and named y, yerr, and axs (previously iterables) for clarity.
  • Loading branch information
jcalbert committed Apr 26, 2019
commit e24476eaaf140c9e951691fce4fba85d280bb0de
31 changes: 15 additions & 16 deletions examples/lines_bars_and_markers/errorbar_subsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,29 @@

# example data
x = np.arange(0.1, 4, 0.1)
y = np.exp(np.vstack([-1.0 * x, -.5 * x]))
y1 = np.exp(-1.0 * x)
y2 = np.exp(-0.5 * x)

# example variable error bar values
yerr = 0.1 + 0.1 * np.sqrt(np.vstack([x, x/2]))
y1err = 0.1 + 0.1 * np.sqrt(x)
y2err = 0.1 + 0.1 * np.sqrt(x/2)


# Now switch to a more OO interface to exercise more features.
fig, axs = plt.subplots(nrows=1, ncols=3, sharex=True, figsize=(12, 6))
ax = axs[0]
for i in range(2):
ax.errorbar(x, y[i], yerr=yerr[i])
fig, (ax_l, ax_c, ax_r) = plt.subplots(nrows=1, ncols=3,
sharex=True, figsize=(12, 6))

ax.set_title('all errorbars')
ax_l.set_title('all errorbars')
ax_l.errorbar(x, y1, yerr=y1err)
ax_l.errorbar(x, y2, yerr=y2err)

ax = axs[1]
for i in range(2):
ax.errorbar(x, y[i], yerr=yerr[i], errorevery=6)
ax.set_title('only every 6th errorbar')
ax_c.set_title('only every 6th errorbar')
ax_c.errorbar(x, y1, yerr=y1err, errorevery=6)
ax_c.errorbar(x, y2, yerr=y2err, errorevery=6)

ax = axs[2]
for i in range(2):
ax.errorbar(x, y[i], yerr=yerr[i], errorevery=(3 * i, 6))
ax.set_title('second series shifted by 3')
ax_r.set_title('second series shifted by 3')
ax_r.errorbar(x, y1, yerr=y1err, errorevery=(0, 6))
ax_r.errorbar(x, y2, yerr=y2err, errorevery=(3, 6))

fig.suptitle('Errorbar subsampling for better appearance')

plt.show()
0