by Michael_Morrison » Sat May 12, 2012 5:17 am
Hi Rob,
Unfortunately, Filling is not a supported option for PolarPlot. However, you can work around this a couple of different ways. Here are some examples:
Show[{
PolarPlot[{1 + 2 Cos[t], 2}, {t, 0, 2 \[Pi]}],
RegionPlot[
2 <= Sqrt[x^2 + y^2] <= 1 + 2 x/Sqrt[(x^2 + y^2)], {x, 0,
3}, {y, -2, 2}, MaxRecursion -> 3, BoundaryStyle -> Thick]}]
Here is another example that uses a slightly different approach by using ParametricPlot and RegionFunction, and then puts everything together with Show:
r[t_] := 1 + 2 Cos[t];
s[t_] := 2;
plot1 = PolarPlot[{r[t], s[t]}, {t, 0, 2 \[Pi]}, PlotStyle -> Thick];
plot2 = ParametricPlot[{u r[t] Cos[t], u r[t] Sin[t]}, {u, 0,
1}, {t, -\[Pi]/3, \[Pi]/3},
RegionFunction -> Function[{x, y, u, t}, u r[t] > s[t]],
Mesh -> None];
Show[{plot1, plot2}, PlotRange -> Automatic]
I do have a custom function I can pass along that will fill a *single* polar plot with a color:
PolarFilledPlot[func_, {var_, varmin_, varmax_}, col_,
opts___?OptionQ] := Module[{conversion, picklesplt, ourplt},
pickles = {opts};
colorval = col;
conversion[Line[l_], colorval_] := {{Hue[colorval], Polygon[l]},
Line[l]};
plt = PolarPlot[func, {var, varmin, varmax},
DisplayFunction -> Identity][[1]];
ourplt =
Show[Graphics[
Cases[plt, _Line, Infinity] /. l_Line :> conversion[l, colorval]],
Evaluate[pickles], DisplayFunction -> $DisplayFunction]
]
Once you evaluate that command in a Mathematica session, you can call the function to create a filled polar plot. (The third argument of the command is the color specification.) For example, here is a polar plot filled with bright cyan:
PolarFilledPlot[Sin[3 t], {t, 0, Pi}, 0.5, Axes -> True]
I hope this helps.
Thanks,
Michael