# Flux lines plot

**URL:** <https://discourse.julialang.org/t/flux-lines-plot/125619>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [February 6, 2025, 12:58pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619 "2025-02-06T12:58:04Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 6, 2025, 12:58pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/1 "2025-02-06T12:58:04Z")

</div>

We would like to produce an image similar to this one:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/3/03707dbd41b41f97127bcd9692c1528f289186fc.jpeg)

except that what we have has nothing to do with climate. We have the density of a property on the surface of a sphere as a function of time.

What are the tools to build such figures?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 6, 2025, 9:13pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/2 "2025-02-06T21:13:25Z")

</div>

In Plots.jl, see a similar idea [here](https://discourse.julialang.org/t/how-to-plot-quiver-plot-over-heatmap/66000/2) of a quiver plot over a heatmap.

---

<div class="post-metadata">

**Author:** ![p\_f](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@p\_f](https://discourse.julialang.org/u/p_f)\
**Post date:** [February 6, 2025, 9:36pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/3 "2025-02-06T21:36:56Z")

</div>

Makie is good for this too: [arrows | Makie](https://docs.makie.org/dev/reference/plots/arrows)

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [February 6, 2025, 11:28pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/4 "2025-02-06T23:28:22Z")

</div>

[This one](https://www.generic-mapping-tools.org/GMTjl_doc/examples/arrows/10_arrows/#example_999538644060835513) is not oceanographic (plate kinematics). See bottom examples, they take two grids (u,v) as input.

 ![example_999538644060835513](https://global.discourse-cdn.com/julialang/original/3X/e/3/e39336c25f425c07809d1ce06d9ec8588d21ca3d.png)

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 7, 2025, 1:53pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/5 "2025-02-07T13:53:03Z")

</div>

These solve the issue of plotting the arrows **given the velocity field**.

Another issue is how to obtain a velocity field from the succession of densities through time. Anyone is aware of a tool for that? It does not seem to be something obvious to implement, but at the same time such tools probably exist to track cloud motions.

Maybe just use differences in density to approximate the time derivative?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 7, 2025, 2:00pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/6 "2025-02-07T14:00:39Z")

</div>

The link I provided calculates the spatial gradient at fixed time. Is it sufficient to show the evolution of spatial gradients over time?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 7, 2025, 2:08pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/7 "2025-02-07T14:08:06Z")

</div>

No, not the same thing.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [February 7, 2025, 8:38pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/8 "2025-02-07T20:38:41Z")

</div>

What about finding local minima and maxima and plot their position along time?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 7, 2025, 9:25pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/9 "2025-02-07T21:25:18Z")

</div>

That depends on finding the maxima, and also probably tracking the maxima among successive frames to create the trajectory. That’s one possibility, but it seems that there isn’t a package (in Julia or otherwise) that already tackled that on some way.

This is the problem as following a trajectory of particles in a video with limited resolution. It must be done. But maybe not open sourced.

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [February 7, 2025, 9:31pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/10 "2025-02-07T21:31:46Z")

</div>

OpenCV has some [Optical Flow](https://docs.opencv.org/3.4/d4/dee/tutorial_optical_flow.html) routines, is that what you need?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 7, 2025, 9:34pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/11 "2025-02-07T21:34:35Z")

</div>

Yes, I guess that’s the kind of thing I’m searching for.

---

<div class="post-metadata">

**Author:** ![apo383](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/apo383/32/11272_2.png) [@apo383](https://discourse.julialang.org/u/apo383)\
**Post date:** [February 7, 2025, 11:43pm UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/12 "2025-02-07T23:43:58Z")

</div>

Does [ImageTracking.jl](https://github.com/JuliaImages/ImageTracking.jl) do what you need? It’s too bad OpenCV isn’t readily available here.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [February 8, 2025, 12:38am UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/13 "2025-02-08T00:38:16Z")

</div>

See the example in  
[https://www.generic-mapping-tools.org/GMTjl\_doc/documentation/utilities/fillsinks/index.html#fillsinks](https://www.generic-mapping-tools.org/GMTjl_doc/documentation/utilities/fillsinks/index.html#fillsinks)

You’ll have the outline of the filled minima and can compute the centroid with `gmtspatial`. Sorry, no converted manual yet but the usage will be some thing like `gmtspatial(D, centroid=true)`. The centroid is not true minimum but it should not be very far. Ofc, this is a Cartesian operation but it should work over a wide range of latitudes but don’t know if it’s able to deal with minima very close to te poles.

---

<div class="post-metadata">

**Author:** ![favba](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/favba/32/2735_2.png) [@favba](https://discourse.julialang.org/u/favba)\
**Post date:** [February 8, 2025, 1:17am UTC](https://discourse.julialang.org/t/flux-lines-plot/125619/14 "2025-02-08T01:17:36Z")

</div>

This is just a guess, and I don’t know much about the field, but what you are describing seems like an [inverse problem](https://en.wikipedia.org/wiki/Inverse_problem).

You have \rho(x, y, z, t) (and therefore you can also compute \frac{\partial\rho}{\partial t} and \nabla \rho) and you want to find \overrightarrow{u}(x, y, z, t) and the equation that connects the two is the transport equation:

\frac{\partial \rho}{\partial t} + \nabla \cdot (\overrightarrow{u} \rho) = 0

Or, if you expect your scalar to be a quantity that naturally diffuses (such as temperature), the equation is:

\frac{\partial \rho}{\partial t} + \nabla \cdot (\overrightarrow{u} \rho) = k\nabla^2 \rho.

But you’d probably need some other constraints on the velocity field to find a solution, maybe \nabla \cdot \overrightarrow{u} = 0.

So that’s what I’d look into, inversion problem tools for transport equations.
