RegionPlot
will usually generate a large number of tiny polygons for filling the region:
RegionPlot[-1 < x < 1 && -1 < y < 1 && x^2 + y^2 > 4/5, {x, -1.2,
1.2}, {y, -1.2, 1.2}, Mesh -> All]
When exported to PDF, these are often not very fast to render.
It is clear that theoretically these polygons could be joined into a single FilledCurve
, defined by the outlines only. This should be much faster to render.
How can we do this in a robust way?
Note: the reason we need a FilledCurve
and that a plain Polygon
will not work is that a FilledCurve
can have a hole in it (it may be multiply connected), like in the image above. Alternatively I will accept a solution which uses more than one Polygon
, but still reduces the number of Polygons
s as much as possible (in the example above two polygons will suffice).
Here's a complex RegionPlot
to test on:
a = 36;
g = RegionPlot[
Mod[Sqrt[x^2 + y^2] - 7/2 ArcTan[x, y] + Sin[x] +
Cos[y], π] < π/2, {x, -a, a}, {y, -a, a},
PlotPoints -> 100]
The equation is from here.