I am getting unexpected plots from PolarPlot when I provide a list of functions that I generate using Table. I suspect the issue is related to the presence of nested lists, but I want to understand how PolarPlot is rendering the nested list of functions.

I expect the output to be a plot showing the curve of each function in my list. I do not know what functional form would generate the plot that I do observe.

For example:

f[a_, b_, c_, t_] := 1 + (1/a)Sin[b + c*t]
t1 = Table[f[a, b, c, t], {a, 3}, {b, 0, Pi/2, Pi/2}, {c, 1}]
PolarPlot[t1, {t, 0, Pi}] (* Not expected result *)
PolarPlot[t1[[1, {1, 2}, {1}]], {t, 0, Pi}] (* Not expected result *)
PolarPlot[Flatten[t1], {t, 0, Pi}] (* Expected result *)
PolarPlot[t1[[1, {1, 2} ,1]],{t, 0, Pi}] (* Expected result *)

It seems that you have already found the solution: to use Flatten. What happens here is that the Table command with several iteration arguments) creates a set of functions nested like this:

{{ {f1[t]}, {f2[t]} },{ {f3[t]} ,{f4[t]} }, ... }

What Plot wants to see as input (check out the help file by hitting F1 on the word PolarPlot to see the exact wording) is a list of functions like

{f1[t], f2[t], f3[t], ... }

Flatten removes all the curly brackets from the original list to give the desired form.

  • $\begingroup$ Thank you. I think I may be best off to clarify the question as being "How does PolarPlot handle nested lists of functions?" I would like to understand what PolarPlot is doing when it encounters something like {{f1[t]},{f2[t]}} as its first argument. $\endgroup$ – James Jun 26 '13 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.