Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0741bc7

Browse files
committed
modified errorbar_subsample example to demonstrate feature
1 parent fee1591 commit 0741bc7

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

examples/lines_bars_and_markers/errorbar_subsample.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,29 @@
1212

1313
# example data
1414
x = np.arange(0.1, 4, 0.1)
15-
y = np.exp(-x)
15+
y = np.exp(np.vstack([-1.0 * x, -.5 * x]))
1616

1717
# example variable error bar values
18-
yerr = 0.1 + 0.1 * np.sqrt(x)
18+
yerr = 0.1 + 0.1 * np.sqrt(np.vstack([x, x/2]))
1919

2020

2121
# Now switch to a more OO interface to exercise more features.
22-
fig, axs = plt.subplots(nrows=1, ncols=2, sharex=True)
22+
fig, axs = plt.subplots(nrows=1, ncols=3, sharex=True, figsize=(12, 6))
2323
ax = axs[0]
24-
ax.errorbar(x, y, yerr=yerr)
24+
for i in range(2):
25+
ax.errorbar(x, y[i], yerr=yerr[i])
26+
2527
ax.set_title('all errorbars')
2628

2729
ax = axs[1]
28-
ax.errorbar(x, y, yerr=yerr, errorevery=5)
29-
ax.set_title('only every 5th errorbar')
30-
30+
for i in range(2):
31+
ax.errorbar(x, y[i], yerr=yerr[i], errorevery=6)
32+
ax.set_title('only every 6th errorbar')
33+
34+
ax = axs[2]
35+
for i in range(2):
36+
ax.errorbar(x, y[i], yerr=yerr[i], errorevery=(3 * i, 6))
37+
ax.set_title('second series shifted by 3')
3138

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

0 commit comments

Comments
 (0)