# Plot 3d vector field

**URL:** <https://discourse.julialang.org/t/plot-3d-vector-field/2117>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [February 15, 2017, 12:18pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117 "2017-02-15T12:18:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [February 15, 2017, 12:18pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/1 "2017-02-15T12:18:58Z")

</div>

I would like to plot a 3d vector field (e.g. a couple of points with arrows attached), with some basic interactivity (rotatate, zoom, pan). What are my options to do this in julia? Are there some example codes with 3d vector fields? Is it possible with Plots.jl?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 15, 2017, 12:41pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/2 "2017-02-15T12:41:52Z")

</div>

Matplotlib (and hence PyPlot) can do this.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [February 15, 2017, 1:42pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/3 "2017-02-15T13:42:42Z")

</div>

Thanks it works! Here is an example for those who may have the same question:

```julia
using PyPlot

pygui(true)

fig = figure()
ax = fig[:gca](projection="3d")

N = 10
x,y,z,u,v,w = [randn(N) for _ in 1:6]
ax[:quiver](x,y,z, u,v,w)

```

---

<div class="post-metadata">

**Author:** ![ramonz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ramonz/32/548_2.png) [@ramonz](https://discourse.julialang.org/u/ramonz)\
**Post date:** [March 6, 2018, 6:31pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/4 "2018-03-06T18:31:06Z")

</div>

Hello.

I have a small problem with quiver in 3d. When setting the axes scale I am unable to set the z axis. x and y axes work well but somehow the 3d projection does not work with z.

Here is the same example as before

using PyPlot

pygui(true)

fig = figure()  
ax = fig:gca

N = 10  
x,y,z,u,v,w = [randn(N) for i in 1:6]  
ax[:quiver](x,y,z, u,v,w)  
axis([-5, 5, -5, 5])

This seems to work, however:

using PyPlot

pygui(true)

fig = figure()  
ax = fig:gca

N = 10  
x,y,z,u,v,w = [randn(N) for i in 1:6]  
ax[:quiver](x,y,z, u,v,w)  
axis([-5, 5, -5, 5, -5, 5])

This throws the following error:  
ValueError(u’v must contain [xmin xmax ymin ymax]',) so only x and y axes are defined

Can anybody help?

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [March 6, 2018, 6:55pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/5 "2018-03-06T18:55:11Z")

</div>

Please quote code blocks with backticks (and without code errors).

```julia
using PyPlot

pygui(true)

fig = figure()
ax = fig[:gca](projection="3d")

N = 10
x,y,z,u,v,w = [randn(N) for _ in 1:6]
ax[:quiver](x,y,z, u,v,w)
xlim([0.0, 1.0])
ylim([0.0, 1.0])
zlim([0.0, 1.0])

```

works for me.

---

<div class="post-metadata">

**Author:** ![ramonz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ramonz/32/548_2.png) [@ramonz](https://discourse.julialang.org/u/ramonz)\
**Post date:** [March 6, 2018, 11:04pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/6 "2018-03-06T23:04:28Z")

</div>

Thanks crstnbr  
It works.  
And sorry I will keep that in mind from now on.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [November 7, 2018, 2:53pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/7 "2018-11-07T14:53:41Z")

</div>

Makie can also do this:  
[http://makie.juliaplots.org/stable/examples-arrows.html#Arrows-3D-1](http://makie.juliaplots.org/stable/examples-arrows.html#Arrows-3D-1)

---

<div class="post-metadata">

**Author:** ![oliver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliver/32/19264_2.png) [@oliver](https://discourse.julialang.org/u/oliver)\
**Post date:** [November 9, 2018, 11:46pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/8 "2018-11-09T23:46:08Z")

</div>

Is Makie supported for 1.0.2? I’m getting errors trying to compile it with `using`.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [November 10, 2018, 1:05am UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/9 "2018-11-10T01:05:35Z")

</div>

just installed 1.0.2 and it seems to work fine on Makie#master AbstractPlotting#master… what version did you install?

---

<div class="post-metadata">

**Author:** ![oliver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliver/32/19264_2.png) [@oliver](https://discourse.julialang.org/u/oliver)\
**Post date:** [November 10, 2018, 5:52pm UTC](https://discourse.julialang.org/t/plot-3d-vector-field/2117/10 "2018-11-10T17:52:02Z")

</div>

```julia
[Info: Precompiling Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a]
ERROR: LoadError: could not open file /home/oliver/.julia/packages/GLFW/pkSlg/deps/deps.jl
ERROR: LoadError: LoadError: Failed to precompile GLFW [f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98] to /home/oliver/.julia/compiled/v1.0/GLFW/n8HlT.ji.
ERROR: Failed to precompile Makie [ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a] to /home/oliver/.julia/compiled/v1.0/Makie/iZ1Bl.ji.

```
