曲线/绘图 Tikz

曲线/绘图 Tikz

我正在尝试制作这张图表:

在此处输入图片描述

这是我目前所做的:

\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}

这是输出:

在此处输入图片描述

除了尝试使用 Tikz 猜测正确的函数之外,还有没有更好的方法?那么,我怎样才能将箭头放在曲线的中间?

谢谢!

答案1

在我看来,这些曲线就像双曲线。至少我认为它们看起来更像双曲线而不是抛物线。

你可以用 tikz 库中的装饰将箭头放在曲线中间decorations.markings。我在我的样式中包含的代码

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

latex在你的道路中间放置一支箭。

我会这么做:

\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}

在此处输入图片描述

编辑:与 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}

答案2

您可以近似您的函数,但这并不像图像上显示的定义函数那么困难:

在此处输入图片描述

\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}

相关内容