2

I was trying to plot complex numbers in Julia but I haven't found any good way to do it yet.

bolov
  • 72,283
  • 15
  • 145
  • 224
  • 1
    As in, on a two dimensional grid? Do you want a contour of a function or just a handful of points? Or are you trying to do something fancy with 3D to plot a function in a fuller way? – Silvio Mayolo Jan 01 '22 at 21:41

2 Answers2

4
using PyPlot
nums = ComplexF64.([1,2,4],[2,2,-1])
polar.(Base.vect.(0.0,angle.(nums)),Base.vect.(0.0,abs.(nums)),marker="o")

enter image description here

Przemyslaw Szufel
  • 40,002
  • 3
  • 32
  • 62
3

One way is to plot the real and imaginary part as x and y

julia> using Plots

julia> d = [0.0000000+0.0000000im, 0.1111111+0.0000000im,
            0.1666667+0.0962250im, 0.2222222+0.0000000im,
            0.3333333+0.0000000im, 0.3888889+0.0962250im,
            0.3333333+0.1924501im, 0.4444444+0.1924501im,
            0.5000000+0.2886751im, 0.5555556+0.1924501im,
            0.6666667+0.1924501im, 0.6111111+0.0962250im,
            0.6666667+0.0000000im, 0.7777778+0.0000000im,
            0.8333333+0.0962250im, 0.8888889+0.0000000im,
            1.0000000+0.0000000im]

julia> plot(real(d),imag(d))
# or directly with plot(d)

plot complex numbers

Andre Wildberg
  • 12,344
  • 3
  • 12
  • 29