|
3 | 3 | Errorbar Limits
|
4 | 4 | ===============
|
5 | 5 |
|
6 |
| -Illustration of upper and lower limit symbols on errorbars |
| 6 | +Illustration of upper and lower limit symbols on errorbars. |
7 | 7 | """
|
8 | 8 |
|
9 | 9 | import numpy as np
|
10 | 10 | import matplotlib.pyplot as plt
|
11 | 11 |
|
12 |
| -############################################################################### |
13 | 12 |
|
14 |
| -fig = plt.figure(0) |
15 |
| -x = np.arange(10.0) |
16 |
| -y = np.sin(np.arange(10.0) / 20.0 * np.pi) |
| 13 | +fig = plt.figure() |
| 14 | +x = np.arange(10) |
| 15 | +y = np.sin(x / 20 * np.pi) |
| 16 | +yerr = np.linspace(0.05, 0.2, 10) |
17 | 17 |
|
18 |
| -plt.errorbar(x, y, yerr=0.1) |
| 18 | +plt.errorbar(x, y, yerr=yerr) |
19 | 19 |
|
20 |
| -y = np.sin(np.arange(10.0) / 20.0 * np.pi) + 1 |
21 |
| -plt.errorbar(x, y, yerr=0.1, uplims=True) |
| 20 | +plt.errorbar(x, y + 1, yerr=yerr, uplims=True) |
22 | 21 |
|
23 |
| -y = np.sin(np.arange(10.0) / 20.0 * np.pi) + 2 |
24 |
| -upperlimits = np.array([1, 0] * 5) |
25 |
| -lowerlimits = np.array([0, 1] * 5) |
26 |
| -plt.errorbar(x, y, yerr=0.1, uplims=upperlimits, lolims=lowerlimits) |
| 22 | +plt.errorbar(x, y + 2, yerr=yerr, uplims=True, lolims=True) |
27 | 23 |
|
28 |
| -plt.xlim(-1, 10) |
| 24 | +upperlimits = [True, False] * 5 |
| 25 | +lowerlimits = [False, True] * 5 |
| 26 | +plt.errorbar(x, y + 3, yerr=yerr, uplims=upperlimits, lolims=lowerlimits) |
29 | 27 |
|
30 | 28 | ###############################################################################
|
31 | 29 |
|
32 | 30 | fig = plt.figure()
|
33 |
| -x = np.arange(10.0) / 10.0 |
| 31 | +x = np.arange(10) / 10 |
34 | 32 | y = (x + 0.1)**2
|
35 | 33 |
|
36 | 34 | plt.errorbar(x, y, xerr=0.1, xlolims=True)
|
|
41 | 39 | y = (x + 0.1)**4
|
42 | 40 | plt.errorbar(x + 1.2, y, xerr=0.1, xuplims=True)
|
43 | 41 |
|
44 |
| -plt.xlim(-0.2, 2.4) |
45 |
| -plt.ylim(-0.1, 1.3) |
46 |
| - |
47 | 42 | plt.show()
|
| 43 | + |
| 44 | +############################################################################# |
| 45 | +# |
| 46 | +# ------------ |
| 47 | +# |
| 48 | +# References |
| 49 | +# """""""""" |
| 50 | +# |
| 51 | +# The use of the following functions, methods, classes and modules is shown |
| 52 | +# in this example: |
| 53 | + |
| 54 | +import matplotlib |
| 55 | +matplotlib.axes.Axes.errorbar |
| 56 | +matplotlib.pyplot.errorbar |
0 commit comments