2
$\begingroup$

I have a function of a parameter $x$ that gives an angle, say $\theta=f(x)$ (not easily invertible), and I want to plot another function of $x$, $g(x)$, in a polar plot. How can I do it?

$\endgroup$
3
  • $\begingroup$ You may calculate some value pairs: {x,phi}, then invert them: {phi,x} and calulate an interpolating function. $\endgroup$ Commented Aug 26, 2022 at 15:34
  • 3
    $\begingroup$ Give an example of $f$ and $g$ or you will only get hand-waving answers. $\endgroup$
    – MarcoB
    Commented Aug 26, 2022 at 15:38
  • $\begingroup$ Does ParametricPlot do what you need? $\endgroup$
    – mikado
    Commented Aug 26, 2022 at 20:31

1 Answer 1

5
$\begingroup$

Since x is in Cartesian Coordinate and θ is in Polar Coordinate, we need to use only one Coordinate.

Method-1

Translate to Polar Coordinate. ( x=r Cos[θ]) and use ParametricPlot and MeshFunction.

Clear[f, x];
f[x_] = x*Sin[2 x^2];
x[r_, θ_] = 
  TransformedField["Cartesian" -> "Polar", x, {x, y} -> {r, θ}];
(*r Cos[θ]*)
ParametricPlot[
 r {Cos[θ], Sin[θ]}, {r, 1, 
  4}, {θ, π/8, π/2}, PlotStyle -> Yellow, 
 BoundaryStyle -> None, 
 MeshFunctions -> 
  Function[{x, y, r, θ}, θ - f[r*Cos[θ]]], 
 Mesh -> {{0}}, Axes -> False, PlotPoints -> 80, MaxRecursion -> 4, 
 MeshStyle -> {Thick, Red}]

enter image description here

Method-2

Translate to Polar Coordinate. ( x=r Cos[θ]),use ContourPlot in {r, θ} coordinate at first and then mapping to {x,y} coordinate.

Clear[f, x];
f[x_] = x*Sin[2 x^2];
x[r_, θ_] = 
  TransformedField["Cartesian" -> "Polar", x, {x, y} -> {r, θ}];
(*r Cos[θ]*)
reg = ParametricPlot[
   r {Cos[θ], Sin[θ]}, {θ, π/8, π/2}, {r,
     1, 4}, PlotStyle -> Yellow, BoundaryStyle -> None];
polar = ContourPlot[θ == f[x[r, θ]], {r, 1, 
    4}, {θ, π/8, π/2}, PlotPoints -> 60, 
   MaxRecursion -> 4, PlotRange -> All];
cartesian = 
  polar /. {r_Real, θ_Real} -> r {Cos[θ], Sin[θ]};
Show[reg, cartesian, Axes -> False]

enter image description here

Method-3

Translate to Cartisian Coordinate. (θ=θ[x, y],r=r[x,y])

Clear[θ, r];
θ[x_, y_] = Arg[x + I*y];
r[x_, y_] = Norm[x + I*y];
f[x_] = x*Sin[2 x^2];
reg = ImplicitRegion[π/8 <= θ[x, y] <= π/2 && 
    1 <= r[x, y] <= 4, {x, y}];
ContourPlot[θ[x, y] == f[x], {x, 0, 5}, {y, 0, 5}, 
 RegionFunction -> Function[{x, y}, {x, y} ∈ reg], 
 Prolog -> {Yellow, DiscretizeRegion[reg]}]

enter image description here

$\endgroup$

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.