2

I'm trying to make this graph:

enter image description here

and this is what I did so far:

\documentclass[tikz, border=20]{report}
\usepackage{tikz,enumitem,multicol}
\usetikzlibrary{arrows}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta,intersections}
\pgfplotsset{compat=1.8}

\begin{document}
\begin{figure}[h]
    \centering
    \begin{tikzpicture}
  \begin{axis}[ultra thick, axis lines=middle,
    xmin=-5, xmax=5, ymin=0, ymax=4, 
    xlabel={\large $K$}, 
    xlabel style={below right}, 
    ylabel={\large $|y|$}, 
    ylabel style={above},
    yticklabels=\empty,
    xticklabels=\empty,
    xtick={0.01, 4},
    xticklabels = {$ $, $ $},
    ]
  
    \addplot[dashed, very thick, samples=300, domain=-3:0, name path=A]{-.75*x};
    
    \addplot[very thick, samples=300, domain=0:3, name path=B] {.75*x};
    
    \addplot[very thick, samples=300, domain=-1:1, name path=B] {x^2  + 1};
    
    \addplot[very thick, samples=300, domain=0.1:3, name path=D] {-abs(x^0.5)/(x^2) + 1.5};
    
    \addplot[very thick, samples=300, domain=-0.1:-3, name path=D] {-abs(x)/(x^2) + 1.5};
    
    \end{axis}
\end{tikzpicture}
    \caption{In this figure, we present the RG flow ...}
    \label{fig:RG_flow}
\end{figure}

\end{document}

This is the output:

enter image description here

Is there a better way instead of try to guess the right function with Tikz? Then, how can I put the arrow in the middle of the curves?

Thanks!

6

The curves look like hyperbolas to me. At least I think they look more like hyperbolas than parabolas.

You can put the arrows in the middle of the curves with a decoration, from tikz library decorations.markings. The code that I include in my style

mark=at position 0.5 with {\arrow{latex}}}

puts a latex arrow in the middle of your path.

This is what I'd do:

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{decorations.markings}

\tikzset{%
  my arrow/.style={
    postaction={decorate,decoration={
    markings,
    mark=at position 0.5 with {\arrow{latex}}}
    }}
}

\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,thick]
  % axes
  \draw[-latex] (-4,0) -- (4,0) node [below] {$K$};
  \draw[-latex] ( 0,0) -- (0,4) node [below right] {$|y|$};
  % blue lines
  \draw[blue,my arrow]        (4,4) -- ( 0,0);
  \draw[blue,dotted,my arrow] (0,0) -- (-4,4);
  % red curve (hyperbola)
  \draw[red,my arrow] plot [smooth,domain=4:-4,samples=41] (\x,{sqrt(2+\x*\x)});
  % green curves (hyperbolas)
  \draw[green!50!black,my arrow] plot [smooth,domain=4:0,samples=21]  ({sqrt(2+\x*\x)},\x);
  \draw[green!50!black,my arrow] plot [smooth,domain=0:4,samples=21] ({-sqrt(2+\x*\x)},\x);
  % labels
  \node at (0,0)         [below] {$K_c$};
  \node at ({sqrt(2)},0) [below] {$K^*$};
  \node at (3,2) {(a)};
  \node at (0,2) [right] {(b)};
  \node at (-3,2) {(c)};
\end{tikzpicture}
\end{document}

enter image description here

Edit: The same plot with pgfplots:

\documentclass[border=2mm]{standalone}
\usepackage    {pgfplots} % it loads tikz
\usetikzlibrary{decorations.markings}
\pgfplotsset   {compat=1.17}

\tikzset{%
  my arrow/.style={
    postaction={decorate,decoration={
    markings,
    mark=at position 0.5 with {\arrow{latex}}}
    }}
}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[%
    thick,
    axis lines=middle,
    axis equal,
    xmin=-4, xmax=4, ymin=0, ymax=4, 
    xlabel={$K$}, 
    xlabel style={below}, 
    ylabel={$|y|$}, 
    ylabel style={below right},
    yticklabels=\empty,
    xtick={{sqrt(2)}},
    xticklabels={$K^*$},
    extra x ticks={0},
    extra x tick style={
      xticklabel style={below right}, 
      xticklabel={$K_c$}},
    xtick style={draw=none},
    ytick style={draw=none}
    ]
    % blue lines
    \addplot[blue,dashed,my arrow] coordinates {(0,0) (-4,4)};
    \addplot[blue,my arrow]        coordinates {(4,4) ( 0,0)};
    % red curve (hyperbola)
    \addplot[red,my arrow,samples=41,domain=-4:4] {sqrt(2+\x*\x)};
    % green curves (hyperbolas)
    \addplot[green!50!black,my arrow,samples=21,domain=4:0] ({ sqrt(2+\x*\x)},\x);
    \addplot[green!50!black,my arrow,samples=21,domain=0:4] ({-sqrt(2+\x*\x)},\x);
    % labels
    \addplot[mark=none] coordinates {( 3,2)} node {(a)};
    \addplot[mark=none] coordinates {( 0,2)} node [right] {(b)};
    \addplot[mark=none] coordinates {(-3,2)} node {(c)};
    \end{axis}
\end{tikzpicture}
\end{document}
6
  • thank you! very clear :-)
    – Gnoppi
    Jun 16 at 16:51
  • 1
    +1 Escellent answer. The result is even better than the original graph.
    – SebGlav
    Jun 16 at 17:00
  • How can I colour the region (c) in the left with the command \fill ?
    – Gnoppi
    Jun 17 at 6:39
  • 1
    @DerrickRossi, just add \fill[green,fill opacity=0.2] plot [smooth,domain=0:4,samples=21] ({-sqrt(2+\x*\x)},\x) |- cycle; and you have it Jun 17 at 6:56
  • 1
    @DerrickRossi, |- connects two points drawing first a vertical line and then a horizontal line. And cycle closes the path going to the first point again. Jun 17 at 8:32
3

You can approximate your functions, but this is not less difficult as defined functions shown on your image:

enter image description here

\documentclass[border=2.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                decorations.markings}

\begin{document}
    \begin{tikzpicture}[> = {Straight Barb[scale=0.8]},
->->-/.style={decoration={markings,% switch on markings
                mark=at position 0.25 with {\arrow[line width=1pt]{>}},
                mark=at position 0.75 with {\arrow[line width=1pt]{>}}
                        },
            thick, postaction={decorate}
            },
->-/.style={decoration={markings,% switch on markings
                mark=at position 0.5 with {\arrow[line width=1pt]{>}}
                        },
            thick, postaction={decorate}
            }
                        ]
% axis
\draw[->]   (-3,0) -- (3,0) node[below left] {$K$};
\draw[->]   ( 0,0) node[below] {$K_c$} -- (0,3) node[below left] {$|y|$};
% approximation of functions
\draw[->-]  (3,2.5) -- (0,0);
\draw[->-, dashed]  (0,0) -- (-3,2.5);
%
\draw[->->-] (-2,2.5) .. controls +(1,-2) and +(-1,-2) .. (2,2.5) 
             node[pos=0.75,above] {$(a)$};
%
\draw[->-] (-3,1) .. controls +( 1,-0.25) and +( 0,0.25) .. (-1,0)
             node[pos=0.25,below] {$(b)$};
\draw[->-] ( 3,1) .. controls +(-1,-0.25) and +( 0,0.25) .. ( 1,0) node[below] {$K*$}
             node[pos=0.25,below] {$(c)$};
    \end{tikzpicture}
\end{document}
1
  • Thanks again ;-)
    – Gnoppi
    Jun 16 at 16:52

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.