|
1 | 1 | """
|
2 |
| -=============== |
3 |
| -Errorbar Limits |
4 |
| -=============== |
| 2 | +======================== |
| 3 | +Errorbar limit selection |
| 4 | +======================== |
5 | 5 |
|
6 |
| -Illustration of upper and lower limit symbols on errorbars. |
| 6 | +Illustration of selectively drawing lower and/or upper limit symbols on |
| 7 | +errorbars using the parameters ``uplims``, ``lolims`` of `~.pyplot.errorbar`. |
| 8 | +
|
| 9 | +Alternatively, you can use 2xN values to draw errorbars in only one direction. |
7 | 10 | """
|
8 | 11 |
|
9 | 12 | import numpy as np
|
|
12 | 15 |
|
13 | 16 | fig = plt.figure()
|
14 | 17 | x = np.arange(10)
|
15 |
| -y = np.sin(x / 20 * np.pi) |
| 18 | +y = 2.5 * np.sin(x / 20 * np.pi) |
16 | 19 | yerr = np.linspace(0.05, 0.2, 10)
|
17 | 20 |
|
18 |
| -plt.errorbar(x, y, yerr=yerr) |
| 21 | +plt.errorbar(x, y + 3, yerr=yerr, label='both limits (default)') |
19 | 22 |
|
20 |
| -plt.errorbar(x, y + 1, yerr=yerr, uplims=True) |
| 23 | +plt.errorbar(x, y + 2, yerr=yerr, uplims=True, label='uplims=True') |
21 | 24 |
|
22 |
| -plt.errorbar(x, y + 2, yerr=yerr, uplims=True, lolims=True) |
| 25 | +plt.errorbar(x, y + 1, yerr=yerr, uplims=True, lolims=True, |
| 26 | + label='uplims=True, lolims=True') |
23 | 27 |
|
24 | 28 | upperlimits = [True, False] * 5
|
25 | 29 | lowerlimits = [False, True] * 5
|
26 |
| -plt.errorbar(x, y + 3, yerr=yerr, uplims=upperlimits, lolims=lowerlimits) |
| 30 | +plt.errorbar(x, y, yerr=yerr, uplims=upperlimits, lolims=lowerlimits, |
| 31 | + label='subsets of uplims and lolims') |
| 32 | + |
| 33 | +plt.legend(loc='lower right') |
| 34 | + |
27 | 35 |
|
28 |
| -############################################################################### |
| 36 | +############################################################################## |
| 37 | +# Similarly ``xuplims``and ``xlolims`` can be used on the horizontal ``xerr`` |
| 38 | +# errorbars. |
29 | 39 |
|
30 | 40 | fig = plt.figure()
|
31 | 41 | x = np.arange(10) / 10
|
32 | 42 | y = (x + 0.1)**2
|
33 | 43 |
|
34 |
| -plt.errorbar(x, y, xerr=0.1, xlolims=True) |
| 44 | +plt.errorbar(x, y, xerr=0.1, xlolims=True, label='xlolims=True') |
35 | 45 | y = (x + 0.1)**3
|
36 | 46 |
|
37 |
| -plt.errorbar(x + 0.6, y, xerr=0.1, xuplims=upperlimits, xlolims=lowerlimits) |
| 47 | +plt.errorbar(x + 0.6, y, xerr=0.1, xuplims=upperlimits, xlolims=lowerlimits, |
| 48 | + label='subsets of xuplims and xlolims') |
38 | 49 |
|
39 | 50 | y = (x + 0.1)**4
|
40 |
| -plt.errorbar(x + 1.2, y, xerr=0.1, xuplims=True) |
| 51 | +plt.errorbar(x + 1.2, y, xerr=0.1, xuplims=True, label='xuplims=True') |
41 | 52 |
|
| 53 | +plt.legend() |
42 | 54 | plt.show()
|
43 | 55 |
|
44 |
| -############################################################################# |
| 56 | +############################################################################## |
45 | 57 | #
|
46 | 58 | # ------------
|
47 | 59 | #
|
|
0 commit comments