Correct theta values when drawing a non-circular arc#8047
Correct theta values when drawing a non-circular arc#8047NelleV merged 2 commits intomatplotlib:masterfrom
Conversation
lib/matplotlib/tests/test_axes.py
Outdated
| ax.plot([1, 2, 3]) | ||
|
|
||
|
|
||
| @image_comparison(baseline_images=['arc_angles']) |
There was a problem hiding this comment.
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 |
QuLogic
left a comment
There was a problem hiding this comment.
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.
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)): |
| 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.
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. |
| 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, |
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.