Use Path.arc() to interpolate polar arcs. · matplotlib/matplotlib@73a763a · GitHub
Skip to content

Commit 73a763a

Browse files
committed
Use Path.arc() to interpolate polar arcs.
Currently, in polar plots, arcs are rendered by linearly interpolating in (theta, r) space before conversion to (x, y) space (if their _interpolation_steps attribute is >1 -- this attribute is described in the docs as "an implementation detail not intended for public use"). When _interpolation_steps == 1, this PR doesn't change anything -- there is an example (specialty_plots/radar_chart) that explicitly relies on being able to set _interpolation_steps to 1 and get a "polygonal" polar axes rather than a circular one. When _interpolation_steps > 1, however, this PR looks for paths segments that are either at a constant theta or a constant r. It transforms constant-theta segments to a single segment (because interpolation doesn't help there) and transforms constant-r segments (circular arcs) to a Bezier approximation of a circle which is already implemented in Path.arc()). This greatly decreases the number of control points for such plots in vector outputs (which are thus smaller), and also improves rasterization by mplcairo (cairo appears to be not so good at filling areas with a lot of close vertices). The many changes in baseline images are due to, well, the change of approximation for drawing circles.
1 parent a57c9a1 commit 73a763a

29 files changed

Lines changed: 2541 additions & 7335 deletions

lib/matplotlib/projections/polar.py

Lines changed: 52 additions & 6 deletions
-1.16 KB
Binary file not shown.
-285 Bytes
Loading

lib/matplotlib/tests/baseline_images/test_axes/markevery_polar.svg

Lines changed: 704 additions & 1199 deletions
Loading
-4 Bytes
Loading
-2.96 KB
Binary file not shown.
-1.32 KB
Loading

0 commit comments

Comments
 (0)