-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Polar errcaps #23592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+122
−9
Merged
Polar errcaps #23592
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this works, great! (not sure it will, but my ignorance of sphinx is relatively vast)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just mimicked it from this what's new message, but it does not seem to work properly in the built documentation, so I am not sure it is worth the try.