It does look like "an obscure bug".
A work-around is to construct the polar axes/ticks primitives from scratch. The function polarAxes
below creates angular and radial axes/ticks/gridlines given a radial range (radius
), angular axis origin (startingangle
) and specs for angular/radial ticks/gridlines (each can be specified as an integer or a list). The last two parameters control tick length and radial range padding, respectively.
ClearAll[polarAxes]
polarAxes[radius_: 1, startingangle_: Automatic, angulardivs_: Automatic,
radialdivs_: Automatic, angulargridlines_: Automatic,
radialgridlines_: Automatic, ticklength_: Automatic, axisoffset_: Automatic] :=
Module[{angularticks, radialticks,
r = radius (1 + axisoffset /. Automatic -> .02),
sa = startingangle /. Automatic -> 0, tl = ticklength /. Automatic -> .05},
angularticks = Switch[angulardivs,
_Integer, CirclePoints[{r, sa}, angulardivs],
_List, r Transpose[Through@{Cos, Sin} @ Mod[angulardivs + sa, 2 π]],
_, CirclePoints[{r, sa}, 12]];
radialticks = Switch[radialdivs,
_Integer, Thread[{Subdivide[radius, radialdivs], 0}],
_List, Thread[{radialdivs, 0}],
_, Thread[{Subdivide[radius, 4], 0}]];
{GrayLevel[.4], AbsoluteThickness[.2],
Circle[{0, 0}, r],
Line[{#, # (1 + tl)}] & /@ angularticks,
Line[{{0, 0}, #}] & /@ Switch[angulargridlines,
_Integer, CirclePoints[{r, sa}, angulargridlines],
_List, r Transpose[Through@{Cos, Sin}[Mod[angulargridlines + sa, 2 π]]],
_, angularticks],
Circle[{0, 0}, #] & /@ Switch[radialgridlines,
_Integer, Subdivide[radius, radialgridlines],
_List, radialgridlines,
_, radialticks[[All, 1]]],
MapThread[Text[#, (1 + 3 tl/2) #2, -#2/2] &,
{Most @ Subdivide[0, 2 π, Length @ angularticks], angularticks}],
GeometricTransformation[{
MapThread[Rotate[Text[#, Offset[{0, -5}, #2 + {0, -r tl}], {0, 1}], -sa] &,
{radialticks[[All, 1]], radialticks}],
Line[{#, # + {0, -r tl}}] & /@ radialticks},
RotationTransform[sa]]}]
Examples:
eps = 1;
RegionPlot[Sin[5 x] + Cos[5 y] > 0.2 && Sqrt[x^2 + y^2] < π/2,
{x, -π/2 - eps, π/2 + eps}, {y, -π/2 - eps, π/2 + eps},
ImageSize -> 700, Frame -> False, Axes -> False,
Epilog -> {FontSize -> 12, polarAxes[π/2]}]
Use polarAxes[π/2, π/4]
to make the angular axis start at π/4
:
Use polarAxes[π/2, π/4, 8, Automatic, {0, π/6, π/4, π/2, π, 5 π/6, 17 π/12}, 5]
to get 5 radial grid lines and angular grid lines at {0, π/6, π/4, π/2, π, 5 π/6, 17 π/12}
:
Use polarAxes[π/2, π/4, {0, π/6, π/4, π/2, π, 5 π/6, 17 π/12}, 5, Automatic, 5]
to get angular ticks and gridlines at specified angles and 5 radial ticks/gridlines: