4
$\begingroup$

Given a complex number, z = r*exp(i*psi), how can I use Mathematica to plot the magnitude and phase on a circle? I've put together an example using the following codeenter image description here:

Graphics[{Circle[], Blue, Arrow[{{0, 0}, {1/2, Sqrt[3]/2}}], Red, 
  Point[{1/2, Sqrt[3]/2}]}, Axes -> True]

However, with Mathematica's new complex plotting options, I feel like there is a better way to do it but I haven't been able to figure it out. ComplexListPlot has nice PolarAxes options, but I am unsure if I can use that with an arrow whose length I set. Thanks!

$\endgroup$
4
$\begingroup$
r = 3;
ψ = Pi/4;
ComplexListPlot[{r Exp[I ψ]}, 
 PlotStyle -> Directive[PointSize[Large], Red],
 PlotRange -> {{-4, 4}, {-4, 4}},
 PolarGridLines -> {{{ψ, Directive[Opacity[1], Blue, Thick, Arrowheads[Large]]}}, 
  {{r, Gray}}}] /. Line -> Arrow

enter image description here

For multiple points and arrows:

r = 3;
angles = {Pi/4, 2 Pi/3};
colors = {Red, Magenta};
arrowcolors = {Blue, Green};

ComplexListPlot[{r Exp[I #]} & /@ angles, 
  BaseStyle -> AbsolutePointSize[10],
  PlotRange -> 1.2 r {{-1, 1}, {-1, 1}}, 
  Method -> {"GridLinesInFront" -> True},
  PlotStyle -> colors,
  PolarGridLines -> {MapThread[{#, Directive[Opacity[1], #2, Thick, 
        Arrowheads[Large]]} &, {angles, arrowcolors}], {{r, Gray}}}] /. 
 Line -> (Arrow[#, {0, .15 r}] &)

enter image description here

$\endgroup$
3
$\begingroup$

PolarPlot is what You are looking for.

From the examples this one might be cool:

PolarPlot[Floor[\[Theta]], {\[Theta], 0, 2 Pi}, 
 ExclusionsStyle -> {Dashed, PointSize[Medium]}]

enter image description here

ListPolarPlot offers the example for the polar grid:

ListPolarPlot[Sin[Range[0, 4 Pi, 0.1]], Joined -> True, 
 PlotTheme -> {"Scientific", "Grid"}, ColorFunction -> "DarkRainbow

"]

enter image description here

For the arrow, there is no new built-in available. The enhancement is

AnnotatedArrow[p_, q_, 
  label_] := {Arrowheads[{{-.1, 0}, {.1, .5, 
     Graphics[Inset[Style[label, Medium], {Center, Top}]]}, {.1, 1}}],
   Arrow[{p, q}]}
Graphics[{AnnotatedArrow[{-1, 0}, {1, 0}, "diameter = 2"], Circle[]}]

enter image description here

Look up the documentation for Arrow for further inspiration: Arrow

PlanarAngle provides some convention for the usage. That is new in 12. AnglePath add vector addition conventions. AngleVector represents the mathematical object central in Your question. It can be input to ListPolarPot

Show or Overlay.

A solution in ComplexListPlot is

Show[ComplexListPlot[{0, (1 + I)/Sqrt@2}, PlotStyle -> Thick, 
  Joined -> True, PolarAxes -> Automatic, 
  PolarTicks -> {"Degrees", 0.1}, PolarGridLines -> Automatic], 
 Graphics[Circle[]], PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}, 
 AxesOrigin -> {0, 0}]

enter image description here

$\endgroup$
3
$\begingroup$

You can also use Locator to interactively set the angle and the radius:

Deploy @ DynamicModule[{pt = {3, 3}}, Panel @ 
  Graphics[{Dynamic @ Circle[{0, 0}, Norm[pt]], Point[{0, 0}], 
     Blue, Arrowheads[Large], Dynamic[Arrow[{{0, 0}, pt}]],
     Red, AbsolutePointSize[10], Point@Dynamic[pt], 
     Locator[Dynamic[pt], None], 
     Gray, Dashed, Dynamic[Line@{{pt[[1]], 0}, pt, {0, pt[[2]]}}], 
     Black, Dynamic @ Text[Style[HoldForm[# E^(#2 I)]& @@ 
       Round[{Norm[pt], ArcTan @@ pt}, .1], 14],
       pt 1.1, If[Abs[ArcTan @@ pt] <= Pi/2, {-1, 0}, {1, 0}]]}, 
    Axes -> True,
    Ticks -> Dynamic[Round[{{pt[[1]]}, {pt[[2]]}}, 1/10]], 
    AxesLabel -> (Style[#, 14] & /@ {"Re", "Im"}), 
    PlotRange -> {{-6, 6}, {-6, 6}}, ImageSize -> 400]]

enter image description here

$\endgroup$

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.