From 2b4be36ac8951db60908e5a0b05a03acf442bcb1 Mon Sep 17 00:00:00 2001 From: vas1l <116816275+vas1l@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:57:54 +0000 Subject: [PATCH 1/2] Rotation for theta now includes + np.pi / 2 to adjust the cap properly, sign of y axis condition was adjusted to align properly --- lib/matplotlib/axes/_axes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index de0c6854cbb1..9bca8164ac38 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3770,9 +3770,9 @@ def apply_mask(arrays, mask): for l in caplines[axis]: # Rotate caps to be perpendicular to the error bars for theta, r in zip(l.get_xdata(), l.get_ydata()): - rotation = mtransforms.Affine2D().rotate(theta) + rotation = mtransforms.Affine2D().rotate(theta + np.pi / 2) if axis == 'y': - rotation.rotate(-np.pi / 2) + rotation.rotate(np.pi / 2)#changed sign on "np.pi" ms = mmarkers.MarkerStyle(marker=marker, transform=rotation) self.add_line(mlines.Line2D([theta], [r], marker=ms, From a1f399d939b57e0b20b80e83b8af6f739b6251df Mon Sep 17 00:00:00 2001 From: vas1l <116816275+vas1l@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:12:26 +0000 Subject: [PATCH 2/2] polar error bar fix --- lib/matplotlib/axes/_axes.py | 2 +- test.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test.py diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9bca8164ac38..eedef7230944 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3770,7 +3770,7 @@ def apply_mask(arrays, mask): for l in caplines[axis]: # Rotate caps to be perpendicular to the error bars for theta, r in zip(l.get_xdata(), l.get_ydata()): - rotation = mtransforms.Affine2D().rotate(theta + np.pi / 2) + rotation = mtransforms.Affine2D().rotate(theta + np.pi / 2) #changed rotation coefficient if axis == 'y': rotation.rotate(np.pi / 2)#changed sign on "np.pi" ms = mmarkers.MarkerStyle(marker=marker, diff --git a/test.py b/test.py new file mode 100644 index 000000000000..964971a37c3d --- /dev/null +++ b/test.py @@ -0,0 +1,14 @@ + +import matplotlib.pyplot as plt +import numpy as np + +theta = np.arange(0, 2 * np.pi, np.pi / 8) +r = theta / np.pi / 2 + 0.5 + +fig = plt.figure(figsize=(10, 10)) +ax = fig.add_subplot(projection='polar') +ax.set_theta_zero_location("N") +ax.set_theta_direction(-1) +ax.errorbar(theta, r, xerr=0.1, yerr=0.1, capsize=7, fmt="o", c="seagreen") +ax.set_title("Pretty polar error bars") +plt.show() \ No newline at end of file