|
1 | 1 | """
|
2 |
| -================== |
3 |
| -Errorbar Subsample |
4 |
| -================== |
| 2 | +==================== |
| 3 | +Errorbar subsampling |
| 4 | +==================== |
5 | 5 |
|
6 |
| -Demo for the errorevery keyword to show data full accuracy data plots with |
7 |
| -few errorbars. |
| 6 | +The parameter *errorevery* of `.Axes.errorbar` can be used to draw error bars |
| 7 | +only on a subset of data points. This is particularly useful if there are many |
| 8 | +data points with similar errors. |
8 | 9 | """
|
9 | 10 |
|
10 | 11 | import numpy as np
|
|
20 | 21 | y2err = 0.1 + 0.1 * np.sqrt(x/2)
|
21 | 22 |
|
22 | 23 |
|
23 |
| -# Now switch to a more OO interface to exercise more features. |
24 |
| -fig, (ax_l, ax_c, ax_r) = plt.subplots(nrows=1, ncols=3, |
25 |
| - sharex=True, figsize=(12, 6)) |
| 24 | +fig, (ax0, ax1, ax2) = plt.subplots(nrows=1, ncols=3, sharex=True, |
| 25 | + figsize=(12, 6)) |
26 | 26 |
|
27 |
| -ax_l.set_title('all errorbars') |
28 |
| -ax_l.errorbar(x, y1, yerr=y1err) |
29 |
| -ax_l.errorbar(x, y2, yerr=y2err) |
| 27 | +ax0.set_title('all errorbars') |
| 28 | +ax0.errorbar(x, y1, yerr=y1err) |
| 29 | +ax0.errorbar(x, y2, yerr=y2err) |
30 | 30 |
|
31 |
| -ax_c.set_title('only every 6th errorbar') |
32 |
| -ax_c.errorbar(x, y1, yerr=y1err, errorevery=6) |
33 |
| -ax_c.errorbar(x, y2, yerr=y2err, errorevery=6) |
| 31 | +ax1.set_title('only every 6th errorbar') |
| 32 | +ax1.errorbar(x, y1, yerr=y1err, errorevery=6) |
| 33 | +ax1.errorbar(x, y2, yerr=y2err, errorevery=6) |
34 | 34 |
|
35 |
| -ax_r.set_title('second series shifted by 3') |
36 |
| -ax_r.errorbar(x, y1, yerr=y1err, errorevery=(0, 6)) |
37 |
| -ax_r.errorbar(x, y2, yerr=y2err, errorevery=(3, 6)) |
| 35 | +ax2.set_title('second series shifted by 3') |
| 36 | +ax2.errorbar(x, y1, yerr=y1err, errorevery=(0, 6)) |
| 37 | +ax2.errorbar(x, y2, yerr=y2err, errorevery=(3, 6)) |
38 | 38 |
|
39 |
| -fig.suptitle('Errorbar subsampling for better appearance') |
| 39 | +fig.suptitle('Errorbar subsampling') |
40 | 40 | plt.show()
|
0 commit comments