-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Correct error bar cap orientation in polar plots #28905
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
Conversation
Thanks for picking this up @kyracho! I think it might make sense to adapt your above example into an image comparison test. |
9fe791c
to
063cb88
Compare
@rcomer Thanks! I’ve added the image comparison test based on that example. Let me know if there is anything you'd like me to adjust. @vas1l Appreciate the offer! but I think I’ve got it covered for now. |
00461b7
to
11de4c5
Compare
This is an improvement, but it is not perfect in that you can change the theta offset and direction after the error bars are added:
and then it is broken again: |
Thanks for the suggestion! I initially noticed the behavior too. I’ve tried using if self.name == 'polar':
trans_shift = self.transShift
for axis in caplines:
for l in caplines[axis]:
for theta, r in zip(l.get_xdata(), l.get_ydata()):
# Apply the transShift transformation to adjust theta
transformed_coords = trans_shift.transform([theta, r])
adjusted_theta = transformed_coords[0] # Extract the transformed theta
# Apply rotation based on the transformed theta
if axis == 'y':
rotation = mtransforms.Affine2D().rotate(adjusted_theta - np.pi / 2)
else:
rotation = mtransforms.Affine2D().rotate(adjusted_theta)
# Apply the marker style with the adjusted rotation
ms = mmarkers.MarkerStyle(marker=marker, transform=rotation)
self.add_line(mlines.Line2D([theta], [r], marker=ms, **eb_cap_style))
else:
for axis in caplines:
for l in caplines[axis]:
self.add_line(l) While it does contain the The reason for this is that while Let me know if you have any thoughts or further suggestions on how we could potentially address this! |
5185c4d
to
2b7ac42
Compare
General note: I haven't looked into the update mechanism and how difficult it is to get always consistent updates. The one-time fix in which |
6846653
to
62325e9
Compare
This is because you are transforming So in order to get the runtime changes, we'd have to copy |
@QuLogic thanks! Following feedback, I wrote the The error bars now update correctly when I would appreciate any help or suggestions on passing the CI/CD tests and ensuring the code is optimal. Thanks in advance! |
lib/matplotlib/transforms.py
Outdated
# Adjust theta based on theta_zero_location and theta_direction | ||
adjusted_theta = self._theta_direction * ( | ||
transformed_theta - self._theta_zero_location) |
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 don't understand this; is it not undoing what trans_shift.transform
did?
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.
Hi @QuLogic, I apologize for the confusion and circular logic in my previous push. While it technically worked, I was reapplying transformations unnecessarily. Embarrassing! I’ve since resolved this and cleaned up the approach to ensure the transformations are handled correctly, without redundant steps.
@QuLogic I renamed Also, I wanted to apologize for any confusion caused by my messy commit history. I recent merged main into the PR branch instead of rebasing the PR branch on top of main. This has made it more difficult to squash my commits cleanly, and I realize that it's caused unnecessary complexity in the commit history. I'm working on cleaning it up, and I appreciate your patience while I get things sorted. Moving forward, I’ll be sure to rebase to avoid this issue. |
This is a _very_ straightforward port, and several parts can be cleaned up in future commits.
Hi, I wanted to let you know that while attempting to squash my own commits, I accidentally introduced a bunch of commits that are not my own into the PR. Unfortunately, I haven't been able to return to the previous state before the squash. To keep things clean and avoid further complications, I’m going to create a new branch and open a new PR. I’ll move over my changes and ensure that the commit history is correct in the new PR. Sorry for the confusion and thanks for your patience! |
PR summary
theta_zero_location
andtheta_direction
are set,theta_offset
andtheta_direction
are used to transformtheta
.I'm still working on writing a test to validate the fix and would appreciate any help or suggestions on how best to approach it. Thanks in advance!
Original
_axes.py
:https://github.com/kyracho/matplotlib/blob/bb68469d755bc04e0ddabff3f36908a9e2351423/lib/matplotlib/axes/_axes.py#L3768-L3779
New
_axes.py
:https://github.com/kyracho/matplotlib/blob/210ddbac8c4cec253af6e65baf8803522db7a1bd/lib/matplotlib/axes/_axes.py#L3768-L3782
PR checklist