I have the function $P_{ns}$ which gives me the amplitude of a signal. The angles $\theta_B$ and $\phi_B$ are known. (25 and 180 for example)

    Subscript[P, NS][θ_, ϕ_] = 
  Sin[θ Degree]*Sin[ϕ Degree] *
    Cos[Subscript[θ, B]] - 
   Cos[θ Degree]*Sin[Subscript[θ, B]]*
     Sin[Subscript[ϕ, B]];

This function should be plotted in a polar plot similar to: ListPolarPlot with color given by a function of two variables or to the variable is plotted for a chosen theta value

But in the second case, the color of the line does not change according to the given color function based on the $P_{ns}$ function, where $r$ is $\theta$ and $t$ is $\phi$.

    PolarPlot[{10*π/180, 20*π/180, 30*π/180, 40*π/180, 
     50*π/180, 60*π/180}, {ϕ, 0, 2 π}, 
      PlotStyle -> Thickness[0.02], 
       ColorFunction -> 
    Function[{x, y, r, t}, 
    Hue[Table[Subscript[Pnew, NS][i*10, j*10], {i, 6}, {j, 36}]]], 
   ColorFunctionScaling -> True]
  • $\begingroup$ What is $Pnew_{NS}$? $\endgroup$ Mar 15, 2016 at 0:18
  • $\begingroup$ The initial function is zero. That's a fundamental problem, I guess.. $\endgroup$
    – Rom38
    Mar 15, 2016 at 6:30
  • $\begingroup$ @Rom38 The function is 0 only for ϕ =0 and 180. $\endgroup$
    – Theodora
    Mar 15, 2016 at 7:23
  • $\begingroup$ @DavidG.Stork PnewNS is basically the same function after changing the coordinate system. $\endgroup$
    – Theodora
    Mar 15, 2016 at 7:25

1 Answer 1


As I understood the question of the topic starter, she needs to plot the ContourPlot of the function that is defined by polar coordinates. My solution is done for very similar (but of course, nonzero function):

pns[θ_, ϕ_] := Sin[ϕ]*Cos[θ] - Cos[ϕ]*Sin[θ];

 pns[Sqrt[x^2 + y^2], Arg[x + I*y]], {x, -π, π}, {y, -π, π}, 
 PlotRange -> All, PlotPoints -> 50, 
 RegionFunction -> Function[{x, y}, x^2 + y^2 < 9]]

enter image description here

  • $\begingroup$ Please insert code in a format that can be copied and evaluated as-is. I have edited your post for you this time as an example. $\endgroup$
    – Mr.Wizard
    Mar 15, 2016 at 8:15
  • $\begingroup$ How did you do the Greec letters in code wrappers? I was trying to do it but without success.. $\endgroup$
    – Rom38
    Mar 15, 2016 at 11:40
  • $\begingroup$ To make them pretty use halirutan's toolbar buttons, but if you don't it is better to leave them as e.g. \[Theta] which will copy and paste correctly. $\endgroup$
    – Mr.Wizard
    Mar 15, 2016 at 11:55
  • $\begingroup$ Problem is that I don't need to plot the density for all the values of θ , but only for some specific values, like 10, 20 degrees, etc.. $\endgroup$
    – Theodora
    Mar 15, 2016 at 18:28
  • $\begingroup$ You can to the same as I did, but first make a Table from your function like dat=Table[pns[Sqrt[x^2 + y^2], Arg[x + I*y]], {x, -π, π,step}, {y, -π, π,step}], using the step value what you need. After this you can use the ListContourPlot[dat,<options>] to plot it. Just remove the PlotPoints instruction $\endgroup$
    – Rom38
    Mar 16, 2016 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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