|
4 | 4 | ================================= |
5 | 5 |
|
6 | 6 | 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. |
7 | 11 | """ |
8 | 12 | import numpy as np |
9 | 13 | import matplotlib.pyplot as plt |
10 | 14 |
|
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) |
14 | 16 | 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") |
16 | 32 | plt.show() |
17 | 33 |
|
| 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 | + |
18 | 45 | ############################################################################# |
19 | 46 | # |
20 | 47 | # .. admonition:: References |
|
0 commit comments