I want to draw an similar curve for my bachelor thesis. How can I apply that tikz gives me an similar output as below? The arrows and the seperations (viscous sublayer : buffer layer : logaritmic layer) in the graphic aren't necessary.

enter image description here

  • 1
    You may use pgfplots and the semixaxis environment. Do you have a function (or data) for the red curve? If not you may try to interpolate between the dashed graphs using a bump function. If you have a term or data for the red curve it would be nice if add this information to your question.
    – student
    Dec 15, 2016 at 7:14

1 Answer 1


If you are drawing plots that have a simple function, you can

declare function={kappa:0.8; C=10.8;
                  uplus(\yp)=ln(\yp)/kappa + C;

Then you plot them with normal

\addplot[domain=a:b] {uplus(x)};

That covers both u+ and y+ dashed plots. For the red line, if this plot has real data, then use \addplot table[x=xcolname, y=ycolname]{data.dat}; or something similar (there are several examples here and in the manual about handling data files with PGFplots). If there's a function for it, than the previous mentioned method will also work.

If it's just a representative plot (not real data nor function) you can join both plots with a Bezier curve (..controls (coord)..). To do this you draw part of the first plot, then the Bezier curve and the next part of the other plot:

\draw plot[domain=a:b]{f1(x)} ..controls (<ctr pt>).. (c,{f2(c)}) plot[domain=c:d]{f2(x)}

The ace in the hole here (or the cat's leap for Brazilians) is the placement of the control point (<ctr pt>). A wise choice in this case is the intersection of both plots, but that gives a super smooth transition, so we can shift it a little to better suit our needs. The important part of our code now looks like:

\addplot[domain=a:b1, dashed, name path=uplus] {uplus(x)};
\addplot[domain=a:b2, dashed, name path=yplus] {yplus(x)};
\path[name intersections{of=yplus and uplus}];
\draw[red] plot[domain=a:b]{uplus(x)} ..controls ([shift={(1.5,0)}]intersection-1)..
           (c,{yplus(c)}) plot[domain=c:b2]{yplus(x)};

Unfortunately, for reasons I don't understand the above snippet produces a plot that doesn't perfectly match the \addplot one:

enter image description here

But we can do tha same Thing with \addplots of course, but the red line will be in fact three separate paths, in the previous case it was only one. Finally, to draw the upper labels, is just some clever usage of the coordinate system available (the black dot is just for us to see the <ctr pt>):

enter image description here


\begin{semilogxaxis}[title=Turbulen boundary layer near the wall, title style={yshift=0.5cm},
             ylabel=$\mathrm{u}^+$, ymin=0, ymax=20,
             axis x line=bottom, axis y line=left, axis line style={-stealth},
             declare function={kappa=0.8; C=10.8; uplus(\yp)=ln(\yp)/kappa+C; yplus(\up)=\up;},
             width=16cm, height=10cm, clip=false]
    \addplot[domain=0.01:300, dashed, name path=uplus] {uplus(x)};
    \addplot[domain=0.01:18, smooth, dashed, name path=yplus] {yplus(x)};
    \path[name intersections={of=uplus and yplus}];
    \fill ([shift={(1.5,0)}]intersection-1) circle(1pt); % Dot on the plot
    \addplot[domain=40:300,  red, thick] {uplus(x)} coordinate[pos=0] (i);
    \addplot[domain=0.01:8, red, thick] {yplus(x)} coordinate[pos=1] (j);
    \draw[red, thick, line cap=round] (i) ..controls ([shift={(1.5,0)}]intersection-1).. (j);
% For some reason the below commented code produces a plot different than that of the \addplot for the first plot
%     \draw[red, thick] plot[domain=0.01:8, smooth] (axis cs:\x,{yplus(\x)}) ..controls ([shift={(1.5,0)}]intersection-1).. (axis cs:40,{uplus(40)}) plot[domain=40:300] (axis cs:\x,{uplus(\x)});
    \draw[very thin, gray] (axis description cs:0,1)  coordinate (a) -| coordinate (b) (axis cs:8,0);
    \draw[stealth-stealth] (a) -- node[midway, above]{Viscous} (b);
    \draw[very thin, gray]  (b) -| coordinate (c) (axis cs:40,0);
    \draw[stealth-stealth] (b) -- node[midway, above]{Buffer} (c);
    \draw[stealth-] (c) -- node[midway, above]{Turbulent} (axis description cs:1,1);
  • 1
    Nice. You may add log ticks with fixed point to make the x labels as in OP's example.
    – Julia
    Dec 15, 2016 at 13:01
  • 2
    I left it as a Training exercise for the OP. ;) Dec 15, 2016 at 13:03

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.