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

Skip to content

Commit a7fc4b6

Browse files
committed
More elaborate example of polar error caps.
1 parent b40e2f7 commit a7fc4b6

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

examples/pie_and_polar_charts/polar_error_caps.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,44 @@
44
=================================
55
66
Demo of error bar plot in polar coordinates.
7+
Theta error bars are curved lines ended with caps oriented towards the
8+
center.
9+
Radius error bars are straight lines oriented towards center with
10+
perpendicular caps.
711
"""
812
import numpy as np
913
import matplotlib.pyplot as plt
1014

11-
fig = plt.figure(figsize=(10, 10))
12-
ax = plt.subplot(111, projection='polar')
13-
theta = np.arange(0, 2*np.pi, np.pi / 4)
15+
theta = np.arange(0, 2 * np.pi, np.pi / 4)
1416
r = theta / np.pi / 2 + 0.5
15-
ax.errorbar(theta, r, xerr=0.25, yerr=0.1, capsize=7, fmt="o")
17+
18+
fig = plt.figure(figsize=(10, 10))
19+
ax = fig.add_subplot(projection='polar')
20+
ax.errorbar(theta, r, xerr=0.25, yerr=0.1, capsize=7, fmt="o", c="seagreen")
21+
ax.set_title("Pretty polar error bars")
22+
plt.show()
23+
24+
#############################################################################
25+
# Please acknowledge that large theta error bars will be overlapping.
26+
# This may reduce readability of the output plot. See example figure below:
27+
28+
fig = plt.figure(figsize=(10, 10))
29+
ax = fig.add_subplot(projection='polar')
30+
ax.errorbar(theta, r, xerr=5.25, yerr=0.1, capsize=7, fmt="o", c="darkred")
31+
ax.set_title("Overlapping theta error bars")
1632
plt.show()
1733

34+
#############################################################################
35+
# On the other hand, large radius error bars will never overlap, they just
36+
# lead to unwanted scale in the data, reducing the displayed range.
37+
38+
fig = plt.figure(figsize=(10, 10))
39+
ax = fig.add_subplot(projection='polar')
40+
ax.errorbar(theta, r, xerr=0.25, yerr=10.1, capsize=7, fmt="o", c="orangered")
41+
ax.set_title("Large radius error bars")
42+
plt.show()
43+
44+
1845
#############################################################################
1946
#
2047
# .. admonition:: References

0 commit comments

Comments
 (0)