3D Quiver Plot and animation

I’m trying to plot 3D Quiver plot with Julia Plots package, it appears that Plots still does not support 3D Quiver. so I’m trying to see if there are any other packages such as PyPlot that has the facility to plot 3D Quiver.

using PyCall, PyPlot
using Plots, DataFrames

df = DataFrame()
df.x = [-5 ,-4.552786405 ,-4.105572809 ,-3.211145618 ,-1.422291236 ,0]
df.y = [10 ,9.105572809 ,8.211145618 ,6.422291236 ,2.844582472 ,0]
df.z = [125 ,103.6393202 ,84.27864045 ,51.5572809 ,10.1145618 ,0]
df.u = [0.447213595 ,0.447213595 ,0.894427191 ,1.788854382 ,1.422291236 ,0]
df.v = [-0.894427191 ,-0.894427191 ,-1.788854382 ,-3.577708764 ,-2.844582472 ,0]
df.w = [-21.36067977 ,-19.36067977 ,-32.72135955 ,-41.4427191 ,-10.1145618 ,0]

Here is the output with GNUPLOT:

I’m unable to reproduce this in Julia. When I tried using the following code using PyPlot. I got strange output. Is there any way to create 3D plot in Julia without using PyPlot?

pygui(true)

fig = figure()
ax = fig.gca(projection=“3d”)
ax.quiver(df[!,1],df[!,2],df[!,3],df[!,4],df[!,5],df[!,6])

.

Since I’m unable to post two images because of I’m a new user. Reposting:

I also need to animate this data as shown below. Can you please let me know how can this be achieved in Julia?

Thanks

Makie.jl is the best option for this kind of thing.

1 Like

Thanks, I had difficulty installing Make.jl in first place, exactly the same issue reported here after many hours of struggle I finally installed it.

Unfortunately, the 3D plots and also even regular surface plots did not scale well and did not have proper aspect ratio. Very low quality.

I ended using Plots and marker =:rtriangle that provided work around to create 3D quiver plot. It worked perfectly.

Thanks so much

Using Gaston:

using Gaston

x = [-5 ,-4.552786405 ,-4.105572809 ,-3.211145618 ,-1.422291236 ,0]
y = [10 ,9.105572809 ,8.211145618 ,6.422291236 ,2.844582472 ,0]
z = [125 ,103.6393202 ,84.27864045 ,51.5572809 ,10.1145618 ,0]
dx = [0.447213595 ,0.447213595 ,0.894427191 ,1.788854382 ,1.422291236 ,0]
dy = [-0.894427191 ,-0.894427191 ,-1.788854382 ,-3.577708764 ,-2.844582472 ,0]
dz = [-21.36067977 ,-19.36067977 ,-32.72135955 ,-41.4427191 ,-10.1145618 ,0]

surf(x, y, z, supp = [dx dy dz], w = "vectors filled head", lw = 2,
            Axes(xlabel = :x, ylabel = :y, zlabel = :z, view = (55, 62)))

produces:
image

The animation is easy to obtain with the techniques shown here – don’t hesitate to ask if you need help with it.

4 Likes

Similar to @mbaz solution with Gnuplot the solution is similar…

using Gnuplot
x = [-5 ,-4.552786405 ,-4.105572809 ,-3.211145618 ,-1.422291236 ,0]
y = [10 ,9.105572809 ,8.211145618 ,6.422291236 ,2.844582472 ,0]
z = [125 ,103.6393202 ,84.27864045 ,51.5572809 ,10.1145618 ,0]
dx = [0.447213595 ,0.447213595 ,0.894427191 ,1.788854382 ,1.422291236 ,0]
dy = [-0.894427191 ,-0.894427191 ,-1.788854382 ,-3.577708764 ,-2.844582472 ,0]
dz = [-21.36067977 ,-19.36067977 ,-32.72135955 ,-41.4427191 ,-10.1145618 ,0]
@gsp xlab = "x" ylab = "y" zlab = "z" :-
@gsp :- x y z dx dy dz "w vectors filled head lw 1.2 lc 'black' not"

quiver2
this also works in 2D

@gp xlab = "x" ylab = "y" :-
@gp :- x y dx dy "w vectors filled head lw 1.2 lc 'black' not"

quiver2d

2 Likes