I was trying to plot complex numbers in Julia but I haven't found any good way to do it yet.
Asked
Active
Viewed 1,607 times
2
-
1As 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 Answers
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")

Przemyslaw Szufel
- 40,002
- 3
- 32
- 62
-
Thank you. I tried this but I can't get this code to work because it shows a problem with pyplot backend in Julia, related to matplotlib that I havent found a fix yet. – user3321507 Jan 02 '22 at 16:20
-
1Try: ``using Conda; Conda.runconda(`install -c conda-forge matplotlib`)`` – Przemyslaw Szufel Jan 02 '22 at 16:34
-
I tried your code and some tips from https://github.com/JuliaPy/PyPlot.jl/issues/369 and it worked! Thank you! – user3321507 Jan 02 '22 at 17:34
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)

Andre Wildberg
- 12,344
- 3
- 12
- 29
-
@mcabbott This is in principle a first shot in the dark until we get further info from the OP. – Andre Wildberg Jan 01 '22 at 23:20
-
1