# Is there a streamlines function/package?

**URL:** <https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800>\
**Category:** General Usage\
**Created:** [February 18, 2020, 9:57am UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800 "2020-02-18T09:57:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![timmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timmm/32/6760_2.png) [@timmm](https://discourse.julialang.org/u/timmm)\
**Post date:** [February 18, 2020, 9:57am UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/1 "2020-02-18T09:57:46Z")

</div>

Does anyone know of a package to compute 3D streamlines in Julia?  
Like Matlab’s: [Compute 3-D streamline data - MATLAB stream3 - MathWorks Deutschland](https://de.mathworks.com/help/matlab/ref/stream3.html)  
I specifically want to get the XYZ data describing the streamlines.

If not a package in Python that I can retrieve these with PyCall would also work.

Tim

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [February 18, 2020, 10:37am UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/2 "2020-02-18T10:37:56Z")

</div>

[Mackie.jl streamplot 3d example](http://juliaplots.org/MakieReferenceImages/gallery//streamplot_3d/index.html)

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 18, 2020, 10:38am UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/3 "2020-02-18T10:38:43Z")

</div>

A search shows this discussion on Makie  
[https://github.com/JuliaPlots/Makie.jl/issues/355](https://github.com/JuliaPlots/Makie.jl/issues/355)  
Simon Danisch I am sure will be along here soon!

---

<div class="post-metadata">

**Author:** ![timmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timmm/32/6760_2.png) [@timmm](https://discourse.julialang.org/u/timmm)\
**Post date:** [February 18, 2020, 12:32pm UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/4 "2020-02-18T12:32:05Z")

</div>

OK great, I updated to the latest version of Makie (Julia 1.1.1) and using either  
[http://juliaplots.org/MakieReferenceImages/gallery//streamplot\_1/index.html](http://juliaplots.org/MakieReferenceImages/gallery//streamplot_1/index.html) or  
[http://juliaplots.org/MakieReferenceImages/gallery//streamplot\_3d/index.html](http://juliaplots.org/MakieReferenceImages/gallery//streamplot_3d/index.html) from  
[Home](http://makie.juliaplots.org/stable/) I get the following error:

```julia
streamplot(f, -1.5..1.5, -1.5..1.5, -1.5..1.5, colormap = :magma, gridsize = (10, 10), arrow_size = 0.06)
ERROR: UndefVarError: streamplot not defined
streamplot(f, -1.5..1.5, -1.5..1.5, colormap = :magma)
ERROR: UndefVarError: streamplot not defined

```

Any suggestions? I am also interested to find a way to easily return X Y and Z of the lines.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [February 18, 2020, 1:40pm UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/5 "2020-02-18T13:40:28Z")

</div>

Did you also run `using Mackie`?

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [February 18, 2020, 2:16pm UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/6 "2020-02-18T14:16:23Z")

</div>

Running the full example code works for me (you do have to include `using Makie`, though).

As for getting the lines back, you could dig through the sub-plots of the streamplot. For example (and I haven’t tried this),

```julia
sp = streamplot(...)[end]

sp.plots[1][1] # should be a Vector{Point}

```

---

<div class="post-metadata">

**Author:** ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Post date:** [February 18, 2020, 2:34pm UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/7 "2020-02-18T14:34:10Z")

</div>

If you only need the streamlines you can call the implementation directly:

```julia
arrow_pos, arrow_dir, line_points = AbstractPlotting.streamplot_impl(Point2f0, x->Point2f0(-0.1*x[2], 0.1*x[1]), Rect(0,0,1,1), (100,100), 0.1 )

```

or in 3d

```julia
arrow_pos, arrow_dir, line_points = AbstractPlotting.streamplot_impl(Point3f0, x->Point3f0(-0.1*x[2], 0.1*x[1], -0.1x[3]), Rect(0,0,0,1,1,1), (100,100,100), 0.1 )

```

---

<div class="post-metadata">

**Author:** ![timmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timmm/32/6760_2.png) [@timmm](https://discourse.julialang.org/u/timmm)\
**Post date:** [February 18, 2020, 3:31pm UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/8 "2020-02-18T15:31:56Z")

</div>

Great, I now have it plotting. [mschauer](https://discourse.julialang.org/u/mschauer) do you have an code snippet in 3D where you extract the line data?  
Would I use “Point3f0” and “Cube”?

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Post date:** [February 18, 2020, 3:42pm UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/9 "2020-02-18T15:42:54Z")

</div>

I edited my post.

---

<div class="post-metadata">

**Author:** ![timmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timmm/32/6760_2.png) [@timmm](https://discourse.julialang.org/u/timmm)\
**Post date:** [February 19, 2020, 10:28am UTC](https://discourse.julialang.org/t/is-there-a-streamlines-function-package/34800/10 "2020-02-19T10:28:04Z")

</div>

Great, thanks!
