使用 tikz 添加曲线的方向

使用 tikz 添加曲线的方向

代码:

\begin{tikzpicture}[scale=0.7]
\begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east]
\addlegendimage{empty legend}
\addlegendentry{}
\addplot+[blue, samples=40, variable=\zeta, domain=10:25]
({(0.1 + 0.4)/2 + 1/2*sqrt((0.1 - 0.4)^2 + 2*0.2*1/(0.05*zeta)*(-0.1))},
{1/(2*zeta)*(-0.1)/((0.1 + 0.4)/2 + 1/2*sqrt((0.1 - 0.4)^2 + 
2*0.2*1/(0.05*zeta)*(-0.1)) - 0.1) + (0.1 + 0.4)/2 +  1/2*sqrt((0.1 - 0.4)^2 
+ 2*0.2*1/(0.05*zeta)*(-0.1))});
\addlegendentry{$P^\ast$}
\addplot+[red, samples=40, variable=\zeta, domain=10:25]
({(0.1 + 0.4)/2 - 1/2*sqrt((0.1 - 0.4)^2 + 2*0.2*1/(0.05*zeta)*(-0.1))},
{1/(2*zeta)*(-0.1)/((0.1 + 0.4)/2 - 1/2*sqrt((0.1 - 0.4)^2 + 
2*0.2*1/(0.05*zeta)*(-0.1)) - 0.1) + (0.1 + 0.4)/2 -  1/2*sqrt((0.1 - 0.4)^2 
+ 2*0.2*1/(0.05*zeta)*(-0.1))});
\addlegendentry{$P^\dagger$}
\end{axis}
\end{tikzpicture}

生成以下图像:

在此处输入图片描述

但是,我想添加曲线的“方向”,即它们增加的方向。例如,在图片中,这个方向是从内向外的。有什么方法可以得到它?

答案1

像这样?

\documentclass[border=3.14mm,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{shapes.arrows}
\begin{document}
\begin{tikzpicture}[scale=0.7]
\begin{axis}[xlabel={$s$},ylabel={$c$},legend pos=south east,
enlargelimits=0.2]
\addlegendimage{empty legend}
\addlegendentry{}
\addplot+[blue, samples=40, variable=\zeta, domain=10:25]
({(0.1 + 0.4)/2 + 1/2*sqrt((0.1 - 0.4)^2 + 2*0.2*1/(0.05*zeta)*(-0.1))},
{1/(2*zeta)*(-0.1)/((0.1 + 0.4)/2 + 1/2*sqrt((0.1 - 0.4)^2 + 
2*0.2*1/(0.05*zeta)*(-0.1)) - 0.1) + (0.1 + 0.4)/2 +  1/2*sqrt((0.1 - 0.4)^2 
+ 2*0.2*1/(0.05*zeta)*(-0.1))})
node[midway,above=2ex,sloped,single arrow,fill,text=white,font=\sffamily]
{increasing};
\addlegendentry{$P^\ast$}
\addplot+[red, samples=40, variable=\zeta, domain=10:25]
({(0.1 + 0.4)/2 - 1/2*sqrt((0.1 - 0.4)^2 + 2*0.2*1/(0.05*zeta)*(-0.1))},
{1/(2*zeta)*(-0.1)/((0.1 + 0.4)/2 - 1/2*sqrt((0.1 - 0.4)^2 + 
2*0.2*1/(0.05*zeta)*(-0.1)) - 0.1) + (0.1 + 0.4)/2 -  1/2*sqrt((0.1 - 0.4)^2 
+ 2*0.2*1/(0.05*zeta)*(-0.1))})
node[midway,above=2ex,sloped,single arrow,fill,text=white,font=\sffamily,
shape border rotate=180]
{increasing};
\addlegendentry{$P^\dagger$}
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容