-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23592 from deep-jkl/polar-errcaps
Polar errcaps
- Loading branch information
Showing
5 changed files
with
122 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Fixed errorbars in polar plots | ||
------------------------------ | ||
Caps and error lines are now drawn with respect to polar coordinates, | ||
when plotting errorbars on polar plots. | ||
|
||
.. figure:: /gallery/pie_and_polar_charts/images/sphx_glr_polar_error_caps_001.png | ||
:target: ../../gallery/pie_and_polar_charts/polar_error_caps.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
================================= | ||
Error bar rendering on polar axis | ||
================================= | ||
Demo of error bar plot in polar coordinates. | ||
Theta error bars are curved lines ended with caps oriented towards the | ||
center. | ||
Radius error bars are straight lines oriented towards center with | ||
perpendicular caps. | ||
""" | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
theta = np.arange(0, 2 * np.pi, np.pi / 4) | ||
r = theta / np.pi / 2 + 0.5 | ||
|
||
fig = plt.figure(figsize=(10, 10)) | ||
ax = fig.add_subplot(projection='polar') | ||
ax.errorbar(theta, r, xerr=0.25, yerr=0.1, capsize=7, fmt="o", c="seagreen") | ||
ax.set_title("Pretty polar error bars") | ||
plt.show() | ||
|
||
############################################################################# | ||
# Please acknowledge that large theta error bars will be overlapping. | ||
# This may reduce readability of the output plot. See example figure below: | ||
|
||
fig = plt.figure(figsize=(10, 10)) | ||
ax = fig.add_subplot(projection='polar') | ||
ax.errorbar(theta, r, xerr=5.25, yerr=0.1, capsize=7, fmt="o", c="darkred") | ||
ax.set_title("Overlapping theta error bars") | ||
plt.show() | ||
|
||
############################################################################# | ||
# On the other hand, large radius error bars will never overlap, they just | ||
# lead to unwanted scale in the data, reducing the displayed range. | ||
|
||
fig = plt.figure(figsize=(10, 10)) | ||
ax = fig.add_subplot(projection='polar') | ||
ax.errorbar(theta, r, xerr=0.25, yerr=10.1, capsize=7, fmt="o", c="orangered") | ||
ax.set_title("Large radius error bars") | ||
plt.show() | ||
|
||
|
||
############################################################################# | ||
# | ||
# .. admonition:: References | ||
# | ||
# The use of the following functions, methods, classes and modules is shown | ||
# in this example: | ||
# | ||
# - `matplotlib.axes.Axes.errorbar` / `matplotlib.pyplot.errorbar` | ||
# - `matplotlib.projections.polar` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+81.6 KB
lib/matplotlib/tests/baseline_images/test_axes/mixed_errorbar_polar_caps.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters