-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Correct theta values when drawing a non-circular arc #8047
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
lib/matplotlib/tests/test_axes.py
Outdated
@@ -982,6 +982,23 @@ def test_canonical(): | |||
ax.plot([1, 2, 3]) | |||
|
|||
|
|||
@image_comparison(baseline_images=['arc_angles']) |
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.
add remove_text=True
and style='default'
to the decorator to get the new defaults + drop all of the text (which makes the test more stable).
This will need an entry in whats new or api changes. The paranoid case here is that users have worked around this bug and we are now silently changing things under them so it needs to be documented. |
This looks like the correct place to do this to me. |
Does anyone know why the documentation build is failing with:
|
As far as I understand, it seems like “width” and “height” are |
Would anyone object to me just getting rid of http://matplotlib.org/examples/units/ellipse_with_units.html ? It doesn't seem to be showing any unique capabilities of units, and the 'comparison' just looks the same to me. (and does it matter if my new code breaks drawing an ellipse with units?) |
Yes and yes (although, it seems like the problem here is the exact unit implementation, not generally). The unit support is an under-understood, but critical feature of mpl (JPL relies on it). |
As far as I can tell:
so all this means there's no way of converting units within the |
That should fix it, I've moved the new calculation into the |
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.
LGTM mostly. Just a small tweak to the test.
lib/matplotlib/tests/test_axes.py
Outdated
theta2 = i * 360 / 9 | ||
theta1 = theta2 - 45 | ||
ax.add_patch(patches.Arc(centre, w, h, theta1=theta1, theta2=theta2)) | ||
# Straight line should intersect end of arc |
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.
Could you also add the start of the arc as well? Start -> origin -> end should work.
lib/matplotlib/tests/test_axes.py
Outdated
centre = (0.2, 0.5) | ||
|
||
fig, axs = plt.subplots(3, 3) | ||
for i, ax in enumerate(np.ravel(axs)): |
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.
enumerate(axs.flat)
lib/matplotlib/tests/test_axes.py
Outdated
for i, ax in enumerate(np.ravel(axs)): | ||
theta2 = i * 360 / 9 | ||
theta1 = theta2 - 45 | ||
ax.add_patch(patches.Arc(centre, w, h, theta1=theta1, theta2=theta2)) |
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.
Can you also add a full Ellipse
patch with the same parameters but maybe half linewidth or alpha just to show that the arc is in a consistent place?
Thanks for the extra ideas for the test @QuLogic - once this has been reviewed I can squash everything down to a single commit. |
Is there anything backend-specific here? Do we need the SVG/PDF files? |
Oh yes, I forgot that those were optional. I don't think there's anything backend specific, shall I just have a .png image test? |
Yes, I think we can drop the other ones and you can squash this. |
Make arcs work with units Add api change not for elliptical notes Add background ellipse and extra line to test Remove pdf and svg tests for arc angles
Great, that should be all nicely squashed up now. |
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.
One more minor thing.
The `matplotlib.patches.Arc` patch is now correctly drawn between the given | ||
angles. | ||
|
||
Previously a circular are was drawn and then stretched into an ellipse, |
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.
are -> arc
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.
woops...
Fixes #8046. I'm not sure if this is the right place to do the correction, so a second opinion would be good. I've checked this works with a full range of angles.