# Mathematica 10.2 Problem with Shading between polar graphs

I've been studying the page Shading between polar graphs and there seems to be some sort of common problem with a number of the Answers. I am using Mathematica 10.2 on a MacBook Pro laptop (10.10.4). For example, when I try this code, after exiting Mathematica, starting Mathematica, and opening a new notebook:

Show[PolarPlot[{{1, -1} Sqrt[2 Cos[t]],
2 (1 - Cos[t])}, {t, -\[Pi], \[Pi]}],
RegionPlot[
Sqrt[x^2 + y^2] > 2 (1 - Cos[ArcTan[x, y]]) &&
Sqrt[x^2 + y^2] < Re@Sqrt[2 Cos[ArcTan[x, y]]], {x, -2, 2}, {y, -3,
3}], PlotRange -> All]


I get this image:

A very similar image mistake also occurs with several other answers.

Thoughs?

Reply to Guess who it is:

Show[PolarPlot[{{1, -1} Sqrt[2 Cos[t]],
2 (1 - Cos[t])}, {t, -\[Pi], \[Pi]}],
RegionPlot[
Sqrt[x^2 + y^2] > 2 (1 - Cos[ArcTan[x, y]]) &&
Sqrt[x^2 + y^2] < Re@Sqrt[2 Cos[ArcTan[x, y]]], {x, -2, 2}, {y, -3,
3}], PlotRange -> All,
Method -> {"TransparentPolygonMesh" -> True}]


But note that there is still a problem.

So I don't think this is quite a duplicate.

eqns[t_] := {Sqrt[2 Cos[t]], 2 (1 - Cos[t])};
region = PolarPlot[eqns[t], {t, -\[Pi], \[Pi]},
RegionFunction ->
Function[{x, y, t, r}, {#1 > #2} & @@ Re[eqns[t]] // First]];
pts = Cases[region, Line[x___] :> x, Infinity];
colors = {Darker@Green, Blue};

Show[PolarPlot[Evaluate@eqns[t], {t, -\[Pi], \[Pi]},
PlotStyle -> colors],
ListLinePlot[pts, PlotStyle -> colors, Filling -> Axis,
FillingStyle -> LightGreen], PlotRange -> All]


• Have you tried that solution I showed earlier? It's the exact same problem. Commented Aug 14, 2015 at 18:09
• @J. M. See my update to my original post. Commented Aug 14, 2015 at 18:33
• If I understand what you are referring to as "the problem", i.e. the appearance of that straight line instead of the polar curve, you can simply Evaluate the argument of PolarPlot, which otherwise has a HoldAll attribute: PolarPlot[ Evaluate@{{1, -1} Sqrt[2 Cos[t]], 2 (1 - Cos[t])}, {t, Pi, Pi}] which generates this plot. Nevertheless, there is still something weird here: clearly this evaluation wasn't needed in 2012 when those questions and answers you linked to were generated. Has something changed within PolarPlot since then? Commented Aug 14, 2015 at 19:43
• It would help if the question were more explicit that "Thoughs?" The main problem prima facie is the mesh, which is what the title of the question is about. The update still does not make clear what the problem is, although I think MarcoB has identified the next most likely thing. If it is the line, then the problem is simply PolarPlot[{{1, -1} Sqrt[2 Cos[t]]}, {t, -Pi, Pi}] without the other stuff to distract us. Commented Aug 14, 2015 at 22:14
• @MichaelE2 Yes, MarcoB did interpret correctly the problem after I added Guess who it is suggestion. But this is not my code. It came from the page Shading between polar graphs and there are about three answers there now that no longer work. As MarcoB said, there is something weird going on. I was just sort of trying to report it because that page is a potentially great page. Commented Aug 15, 2015 at 1:02

Basically, one should expect

PolarPlot[f1[t],...]


to plot parametrically the curve {f1[t] Cos[t], f1[t] Sin[t]}. When there is a list of more than one function {f1[t], f2[t],...}, then it should do the same for each function.

Like all the function-plotting commands PolarPlot is HoldAll. What should happen when the function call is of the following form, as it is in this case?

PolarPlot[{{-1, 1} f1[t], f2[t]},...]


Well, of course the user would like it to plot {-f1[t], f1[t], f2[t]}, flattening out the list. But in its unevaluated state, it has the form

PolarPlot[{g1[t], f2[t]},...]


As it turns out, at least in V10, from the first element is constructed

{g1[t] Cos[t], g1[t] Sin[t]}


which evaluates to two parametrizations

{ {-f1[t] Cos[t], f1[t] Cos[t]},   {-f1[t] Sin[t], f1[t] Sin[t]} }


and each of these parametrizes the same line y == -x. (At some point, the list must be parsed into two parametrizations in order to construct a plot at all. However the parsing happens, it is after the threading with Cos[t] and Sin[t] as shown above.) Note the same thing happens with the simpler command

PolarPlot[{-1, 1} Sqrt[2 Cos[t]]}, {t, -Pi, Pi}]


A proper fix would be

PolarPlot[Evaluate@Flatten@{{1, -1} Sqrt[2 Cos[t]], 2 (1 - Cos[t])}, {t, -Pi, Pi}]


but as pointed out in the comments, the following suffices (in the current version V10.2):

PolarPlot[Evaluate@{{1, -1} Sqrt[2 Cos[t]], 2 (1 - Cos[t])}, {t, -Pi, Pi}]

• Nice investigation. I hope folks update their code on [Shading between polar graphs]{mathematica.stackexchange.com/questions/5087/…} because there is some very helpful work there. Commented Aug 15, 2015 at 2:33