|
12 | 12 |
|
13 | 13 | # example data
|
14 | 14 | x = np.arange(0.1, 4, 0.1)
|
15 |
| -y = np.exp(-x) |
| 15 | +y = np.exp(np.vstack([-1.0 * x, -.5 * x])) |
16 | 16 |
|
17 | 17 | # 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])) |
19 | 19 |
|
20 | 20 |
|
21 | 21 | # 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)) |
23 | 23 | 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 | + |
25 | 27 | ax.set_title('all errorbars')
|
26 | 28 |
|
27 | 29 | 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') |
31 | 38 |
|
32 | 39 | fig.suptitle('Errorbar subsampling for better appearance')
|
33 | 40 |
|
|
0 commit comments