I want to visualize a turbulent flow regime. Assumed we have a simple empty square that should be filled with a pattern.

Minimum Working Example (MWE):


   \draw (0, 0) rectangle (4, 4);

I won't post a screenshot, because it is just a simple rectangle. :-)

How can I fill this rectangle with a pattern like this on the right side:

Screenshot of the desired pattern

Or, for the advanced TeX-users: How to fill it with a pattern like this one (made of random arrows)?

Screenshot of the perfect state

Thanks to marmot: As you can see, the arrows never intersect - this seems to be a challenge.

  • Here is a question on randomly curved arrows. It is not difficult to draw random arrows, but if I interpret your question correctly, they should not intersect. Avoiding intersections is probably more efforts. So I wish to clarify: you do not want the arrows to intersect? – user121799 Mar 31 '19 at 16:35
  • @marmot: Thanks for your comment - you are completely right! The arrows should not intersect, because the fluid can not cross in reality. – Dave Mar 31 '19 at 16:48
  • 1
    As a proof of concept, I'm very interested in how this can be coded (+1 to mamot, indeed) but from a practical point of view (time and result quality) I would do it manually in Inkscape. – Fran Mar 31 '19 at 18:09
  • @Fran: I took me the whole weekend to put and adjust some spirals into my tikzpicture. Therefore I am curious if there is a better solution available for it. – Dave Mar 31 '19 at 18:12

This is an answer to the question

How can one draw some randomly curved arrows that do not intersect?

which is not to be confused with

How can I draw the velocity field of some fluid?

which may require a model, a solution of the Navier-Stokes equations or something of that sort. That is, forbidding intersections is a step in the right direction but does not yield a physical description. If you do have the parametrization a realistic turbulent velocity field, you can do much better.

%\draw[clip] (0,0) rectangle (4,4);
\foreach \X in {1,...,50}
\path[-{Latex},name path=test-arc] plot[smooth,tension=1] 
coordinates {(\myx,\myy) (\myxp,\myyp) (\myxq,\myyq) (\myxr,\myyr) };
 \foreach \Y in {1,...,\number\value{randarcs}}
 {\path[name intersections={of=\Y-arc and test-arc,total=\t},
    plot[smooth,tension=1] coordinates {(\myx,\myy) (\myxp,\myyp)
    (\myxq,\myyq)  (\myxr,\myyr)};
    \path[name path global=\number\value{randarcs}-arc]
    plot[smooth,tension=1] coordinates {(\myx,\myy) (\myxp,\myyp)
    (\myxq,\myyq)  (\myxr,\myyr)} -- cycle;
\typeout{\number\value{randarcs}\space arcs\space drawn.}

enter image description here

| improve this answer | |
  • Awesome, thank you very much! :-) Would it be possible to get the arrows a bit more "smooth"? They seem to be very edgy. – Dave Mar 31 '19 at 18:07
  • 1
    @Dave I changed some parameters. In addition, you can play with tension. E.g. replace all tension=1 with tension=1.6. It also helps to play with \pgfmathsetseed{21}. – user121799 Mar 31 '19 at 18:23

This is not an answer but an attempt to show that some type of vectorial art could be done without coding yourself as this could help to new users without a high LateX - tikz - maths training to produce high quality images.

The main point is that SVG files made with Inkscape, can be saved like pure TeX (PStricks) code and then used in a LaTeX document without loss of quality because are still a code to render a vectorial image. But sadly , the generated coded, said foo.tex, is not compilable as is, and will cryptically warning you:

%% Please note this file requires PSTricks extensions

What the hell mean that? Simply that you must make a LaTeX document with this two lines in the preamble::

\usepackage[pdf]{pstricks} % "pdf" to use with `pdflatex`!

And then in some part of your document (in a figure float, for instance) add:


The result:

enter image description here

The other option is save the vectorial image as PDF (or EPS), that can be used just like any PNG or JPG image with the usual \includegraphics of the graphicx package. This have the advantage that can use some effects as color gradients or transparencies that are not well exported to PSTricks and also reduce the compilation time. Note that using PStricks you cannot use the PDF but the EPS images. However with an updated distribution you still can use pdflatex using the option [pdf] of pstricks package.


Full MWE:

\usepackage[pdf]{pstricks} % "pdf" to use with `pdflatex`!


\input{foo2} % foo2.tex directly saved with Inkscape with a pspicture  
\caption{A pstricks draw made with Inkscape. Only \TeX\ code here.}

\caption{EPS -- PDF version with gradients.}


Note: The code of foo.texis too long to be posted and of scarce interest since is automatically generated from a manual draw. If you are curious about how is that code, is like this simple draw:


{\newrgbcolor{curcolor}{.8 .9 .8} % Box

{\newrgbcolor{curcolor}{1 .2 1} % line

{\newrgbcolor{curcolor}{.4 .8 .4} % arrowhead head

{\newrgbcolor{curcolor}{0 0 1} % arrowhead border

I left as exercise recreate the turbulence image in the same way. However, the equation of the image was typeset (inside Inkscape) using this LaTeX code:

\frac{ \partial \overline{u_{i}} }{\partial t} +
\overline{u_{j}} \frac{ \partial \overline{u_{i}} }{ \partial x_{j} } =
- \frac{1}{\rho} \frac{\partial \overline{p} }{ \partial x_{i} }
   + \frac{1}{\rho} \frac{\partial}{\partial x_{j}} 
\left( \mu \frac{\partial \overline{u_{i}}}{\partial x_{j}} -
              \rho \overline{u_i^\prime u_j^\prime } \right) 
| improve this answer | |
  • 1
    Very nice! +1. Perhaps you could also add that potrace has the ability to convert an existing bitmap to a vector graphics format. The latter can be loaded in inkscape and then converted to svg, TikZ or PSTricks. This way you do not even have to draw the arcs in inkscape. – user121799 Apr 1 '19 at 2:54
  • 1
    @marmot Inkscape can also nicely vectorize bitmaps (and even show a preview according to the settings). These tools are really useful for complex shapes like human silhouettes, but objects like arrow tails are traced as shapes instead as single bezier curve, so any fix of control points in these closely parallel curves, including convert the shape it single line, is a pain. Instead, draw manually a single line with 3-4 controls points is a child play, and the line will be always of the same fixed width. So for this case I was the tracing tool. :) – Fran Apr 1 '19 at 9:30

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.