# Angular Range in Polar Plot

I am trying to make a polar plot using the following code

PolarPlot[1, {θ, 0, Pi/3}, PolarAxes -> True,
PolarTicks -> {"Degrees", Automatic}, PolarGridLines -> True,
PlotRange -> 1.5]


What I would like to do is to set the angle range of the polar axis, from 0 to 60 degrees. I've tried using PlotRange but this changes the radial component of the function...

How is it possible to define an anglular range of a polar plot?

Edit

Original post at the end. This is uglier, but cleaner and more robust:

tmax = Pi/3;
rmax = 1.5;
u = PolarPlot[t (*Your function Here*), {t, 0, Pi},
PolarAxes -> {True, True}, PolarTicks -> {"Degrees", Automatic},
PolarGridLines -> True, PlotRange -> rmax,
RegionFunction -> Function[{x, y, t, r}, t < tmax],
PolarAxesOrigin -> {0, rmax}, PolarAxes -> 0];
Show[Quiet@
Replace[u,
{Circle[{0, 0}, x_, {0, 2 Pi}] -> Circle[{0, 0}, x, {0, tmax}],
Line[{x_, y_}] /;  tmax < ArcTan[y[[1]], y[[2]]] || 0 > ArcTan[y[[1]], y[[2]]] :> {},
Line[{Scaled[x1_, y1_], Scaled[x2_, y2_]}] /;
tmax < ArcTan[y2[[1]] + x2[[1]], y2[[2]] + x2[[2]]] ||
0 > ArcTan[y2[[1]] + x2[[1]], y2[[2]] + x2[[2]]] :> {},
{{a_ (Sin | Cos)[y_], b_  (Sin | Cos)[y_]},
Scaled[{s_, t_}, {c_ (Sin | Cos)[y_], d_ (Sin | Cos)[y_]}]} /;
ArcTan[s, t] > tmax || ArcTan[s, t] < 0 -> {},
Text[Style[TraditionalForm[Times[x_, Degree]], List[]], __] /; x > tmax (180/Pi) :> {}},
Infinity],
PlotRange -> {{0, rmax}, {0, rmax Sin[tmax]}}]


Original post I know this is no beauty, but just an idea:

rmax = 1.5;
Show[
PolarPlot[1.3 t (*Your function Here*), {t, 0, Pi},
PolarAxes -> {True, False},
PolarTicks -> {"Degrees", Automatic}, PolarGridLines -> True,
PlotRange -> rmax,
RegionFunction -> Function[{x, y, t, r}, t < Pi/3],
PolarAxesOrigin -> {0, rmax}],

Graphics[{White, Disk[{0, 0}, rmax  2, {0 - 1/15, -5/3 Pi + 1/20}]}],

PolarPlot[rmax, {t, 0, Pi/3}, PolarAxes -> {False, True},
PolarTicks -> {None, Automatic}, PolarGridLines -> False,
PlotRange -> rmax, PolarAxesOrigin -> {0, rmax},
PolarAxes -> 0]
,PlotRange -> {{0, rmax}, {0, rmax Sin[Pi/3]}}]


The

{0 - 1/15, -5/3 Pi + 1/20}


needs some elaboration, for sure.

• Why not set PlotRange -> {{0, rmax}, {0, rmax Sin[Pi/3]}}, but outside Graphics, as an option to Show. Feb 21, 2013 at 23:52
• @MichaelE2 Thanks, updated. Is that what you meant? Feb 21, 2013 at 23:55
• Yep. Looks better, even if a bit of a hack. (+1) Feb 21, 2013 at 23:57
• @MichaelE2 It is much worse than a hack! And I'm not really sure that it will work in most situations, but I'm really clueless about how do it better. Feb 21, 2013 at 23:58
• Yes, I looked at it and punted. It doesn't seem that PolarPlot is set up to handle this sort of situation. Still your answer lets the OP do what is asked. Maybe someone will post a better approach. Feb 22, 2013 at 0:04

What is most interesting is, unlike Plot, PolarPlot uses explicit graphics primitives to present axes and grids, so we can "filter" out things which is out of our interested range by force (though which is not a beautiful method).

Here is my brute-force function. I've made it capable of dealing with range crossing $\theta=0$, but yet added a feature which should rotate the axes into the interested range when it's not.

Clear[polarRangeFunc]
polarRangeFunc[graph_, \[Alpha]_, \[Beta]_] :=
Module[{\[Theta]min, \[Theta]max, sgn, rangeFunc},
{\[Theta]min, \[Theta]max} = Sort[Mod[{\[Alpha], \[Beta]}, 2 \[Pi]]];
sgn = Sign[\[Alpha] \[Beta]];
rangeFunc[pos_] :=
If[pos == {0, 0}, False,
If[sgn == -1, #, Not@#] &[\[Theta]min <=
Mod[Arg[{1, I}.pos], 2 \[Pi]] <= \[Theta]max]];
graph /. (PlotRange -> _) :> AbsoluteOptions[Graphics[{
Disk[{0, 0},
Max[Abs[
PlotRange /.
AbsoluteOptions[graph, PlotRange]]], {\[Alpha], \[Beta]}]
}], PlotRange] //
ReplacePart[#, {1, 5} -> (#[[1, 5]] /.
{Line[{Scaled[_, pos_], Scaled[_, pos_]}] /;
rangeFunc[pos] :> Line[{}],
annoymousTicks_?(MatchQ[#,
Line[{{{_, _}, Scaled[__]} ..}]] &) :>
(annoymousTicks /. {pos_, Scaled[__]} /; rangeFunc[pos] :>
Sequence[]),
Text[_,
Offset[_, pos_], ___] /; (rangeFunc@
If[Head[pos] === Scaled, pos[[2]], pos]) :> Sequence[],
Circle[orig_, radius_, angleRange_] :>
Circle[orig, radius, {\[Alpha], \[Beta]}]}
)] & //
ReplacePart[#, {1, 1} -> (#[[1, 1]] /.
{Line[{{0, 0}, pos_}] /; rangeFunc[pos] :> Line[{}],
Circle[orig_, radius_, angleRange_] :>
Circle[orig, radius, {\[Alpha], \[Beta]}]}
)] & //
ReplacePart[#, {1, 3} -> (#[[1, 3]] /.
Line[pts_] :>
Line[pts /. {x_, y_} /; rangeFunc[{x, y}] :> "outpt" //
(SplitBy[#, StringQ] /. "outpt" -> Sequence[]) &]
)] &
]


And here is an example:

polorgraph =
PolarPlot[{2 \[Theta]^(-1/3), 3 Cos[\[Theta]^(1/2)]},
{\[Theta], .01, 10 \[Pi]},
PlotStyle -> {Directive[Red, Thick], Directive[Purple, Thick]},
PolarAxes -> True, PolarAxesOrigin -> {\[Pi]/6, 3}, PlotRange -> 3,
PolarTicks -> {"Degrees", Automatic}, PolarGridLines -> True]


polarRangeFunc[polorgraph, \[Pi]/6, \[Pi]/2]


polarRangeFunc[polorgraph, -\[Pi]/6, 6 \[Pi]/5]


• Aren't the radial tick labels curiously positioned? (Same in my answer) Feb 22, 2013 at 18:41
• @belisarius See my edit please. I modified the rangeFunc function to include a special case at {0,0}. Feb 22, 2013 at 19:34
• Much better :). Feb 22, 2013 at 20:04
• @belisarius Thanks:) There are still problem about the cutting-off of the function line on the boundaries. I should add an interpolation, but it's already a mess of code, I kind of feel tired to modify it now.+_+||| Feb 23, 2013 at 4:03
• I think that could be fixed with RegionFunction, but anyway agree: this is too much code for a narrow usage universe. Let it be :) Feb 23, 2013 at 4:07