-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: Make stem() baseline follow the curvature in polar plots #29486
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
c55c0ad
to
b3d768f
Compare
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.
Is 200 points enough? at 300 dpi (kind of usual publication quality) that would be a 1.7 cm circle which seems pretty small. Can we not use an Arc here?
(edit to correct 1.7 mm -> 1.7 cm)
I’m not clear what you’ve calculated. Approximating a circle through a regular polygon with 200 nodes should not be visually distinguishable from a circle in all typical use cases. In fact, I believe 200 is more on the safe side. This is a relatively cheap workaround. I’d rather not make the Artist type dependent on the Axes. |
200 dots /(300 dots/inch) * 2.54 cm / inch=1.693 cm (I mistakenly typed mm instead of cm).
That seems overly broad - if you don't want to do this "properly" (though I'm not sure that the type stability should be a concern here) then I'd at least use more points. |
Sorry, I’m still not clear. 200 are not some “dots” related to dpi, but the number of nodes in the approximating polygon. What you need to look at is the maximal deviation from the circle. See https://math.stackexchange.com/a/4132095. If I have calculated correctly from the top of my head n=200 results in D = 1e-4 R. So if you have a circle with R=1000px radius the maximal deviation is D=0.1px. FWIW, I asked chatGPT for a recommendation on the number of nodes:
So, IMHO 200 is enough. |
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.
OK< fair enough - I agree, certainly compared to other imperfections this is almost impossible to detect.
This should probably use the same intepolation method as matplotlib/lib/matplotlib/axes/_axes.py Line 805 in c2d502d
Or in fact, maybe it should use |
b3d768f
to
742fbe1
Compare
Thanks, it seems I've changed the test to "check that the baseline is reasonably interpolated, by verifying it has a large number of interpolation steps". This is a bit weak as it does only test the setting not the visual effect. OTOH I think it's not worth to add a test image and an image-comparison check that is less tautolgical is also hard (just manually drawing a line with |
742fbe1
to
05af7bf
Compare
Note: There's precedence for a similar special-casing on polar Axes for errorbars: https://github.com/matplotlib/matplotlib/blob/3fb9c0961b5c8d5753c88ac37c08cda58a4b7839/lib/matplotlib/axes/_axes.py#L3798
05af7bf
to
0225617
Compare
Is there an image test that exercises this? I would expect that to need an update. |
There is no stem() test on a polar plot. Generally, we don’t test all functions with all projections. |
Closes #29484.
Note: There's precedence for a similar special-casing on polar Axes for errorbars:
matplotlib/lib/matplotlib/axes/_axes.py
Line 3798 in 3fb9c09