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

Skip to content

Commit d267a2a

Browse files
authored
Merge pull request #13149 from timhoffm/example-errorbar
Update errorbar limits example
2 parents 58f4ccb + 36159c6 commit d267a2a

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ per-file-ignores =
141141
examples/images_contours_and_fields/tripcolor_demo.py: E201, E402
142142
examples/images_contours_and_fields/triplot_demo.py: E201, E402
143143
examples/images_contours_and_fields/watermark_image.py: E402
144+
examples/lines_bars_and_markers/errorbar_limits_simple.py: E402
144145
examples/lines_bars_and_markers/fill_between_demo.py: E402
145146
examples/lines_bars_and_markers/filled_step.py: E402
146147
examples/lines_bars_and_markers/joinstyle.py: E402

examples/lines_bars_and_markers/errorbar_limits_simple.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,32 @@
33
Errorbar Limits
44
===============
55
6-
Illustration of upper and lower limit symbols on errorbars
6+
Illustration of upper and lower limit symbols on errorbars.
77
"""
88

99
import numpy as np
1010
import matplotlib.pyplot as plt
1111

12-
###############################################################################
1312

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)
1717

18-
plt.errorbar(x, y, yerr=0.1)
18+
plt.errorbar(x, y, yerr=yerr)
1919

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)
2221

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)
2723

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)
2927

3028
###############################################################################
3129

3230
fig = plt.figure()
33-
x = np.arange(10.0) / 10.0
31+
x = np.arange(10) / 10
3432
y = (x + 0.1)**2
3533

3634
plt.errorbar(x, y, xerr=0.1, xlolims=True)
@@ -41,7 +39,18 @@
4139
y = (x + 0.1)**4
4240
plt.errorbar(x + 1.2, y, xerr=0.1, xuplims=True)
4341

44-
plt.xlim(-0.2, 2.4)
45-
plt.ylim(-0.1, 1.3)
46-
4742
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

Comments
 (0)