3

I've just seen 3 Blue 1 Brown's video on divergence and curl and found his diagrams on fluid flow to be so beautiful, especially for an article or book. Now, I'm familiarized with TikZ and PGFPlots, and I know how to do vector graphs and even color diagrams in 2D; but what I'm really looking forward to is having this lines moving around as fluid particles, it would be ideal to do it in LaTeX with some package or some other way if not possible (pic similar to what I want).

3B1B's fluid flow

4

This attempts to address the question how one may generate such plots in principle. I paid no attention to precisely reproducing your (really nice!) screen shot. Here is what I got.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis equal,hide axis,trig format=rad,point meta min=0.4,point meta max=1.8,
 axis background/.style={fill=black}]
    \foreach \Y in {0.2,0.4,...,1}
    {\foreach \X in {1,1.2,1.4,1.6}
    {\edef\temp{\noexpand\pgfmathtruncatemacro{\noexpand\Samples}{20*\X}
    \noexpand\pgfmathsetmacro{\noexpand\ArrowScale}{0.2*\X}
    \noexpand\addplot [samples=\noexpand\Samples, domain=0:2*pi,-stealth,point meta=\X,colormap/hot,
        variable=\noexpand\t,opacity=\Y,quiver={
            u={-sin(t)},
            v={cos(t)},
            scale arrows=\noexpand\ArrowScale,colored,
        },
    ] ( {\X*cos(t)*(1+0.2*sin(4*t))*(1+0.1*sin(2*pi*\Y))}, {\X*2*sin(t)*(1+0.1*sin(2*pi*\Y))} );}
    \temp}}
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Those users who also live in burrows will inevitably be familiar with this parametrization.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.