向曲线添加标签

向曲线添加标签

你能帮我解释一下图片上的内容吗?我需要得到与图片上显示的相同的曲线及其标签,即轴“y 储备”和“x 储备”,以及曲线上的 3 个点,(x_{b},y_{b})以及(x_{a},y_{m})(x_{a},y_{a})

图片

平均能量损失

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{tikzpicture}
\begin{axis}[%
    axis lines = center,
    xlabel = {$T$},
    ylabel = {$E(T)$},
    label style = {anchor=north east},
    xmin = 0, xmax=5,     ymin=0, ymax=1,
    ticks = none,
    enlargelimits=false,
    clip=false,
%
    domain = 1:4,
    samples = 50,
    no marks
            ]
\addplot    {1/x};
\draw[red,  densely dashed]  (0,1/2) node[left] {$E_0$} -| (2,0) node[below] {$T_0$};
\draw[blue, densely dashed]  (0,1/3) node[left] {$E_1$} -| (3,0) node[below] {$T_1$};
\end{axis}
    \end{tikzpicture}
\end{document}

答案1

我可能会先沿曲线定义一些节点或坐标,然后画线来连接它们:

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[%
            axis lines=center,
            xlabel={x reserves},
            ylabel={y reserves},
            x label style={at={(ticklabel cs:0.5)}, anchor=north},
            y label style={at={(ticklabel cs:0.5)}, anchor=south, rotate=90},
            xmin=0.5, xmax=5,
            ymin=0.1, ymax=1,
            ticks=none,
            enlargelimits=false,
            clip=false,
            %
            domain=1:5,
            samples=50,
            no marks
            ]
            \addplot {1/x};
            
            \node[circle, fill, inner sep=1pt, label={45:{$(x_b,y_b)$}}] (a) at (6/5,5/6) {};
            \node[circle, fill, inner sep=1pt, label={45:{$(x_m,y_m)$}}] (b) at (2,1/2) {};
            \node[circle, fill, inner sep=1pt, label={45:{$(x_a,y_a)$}}] (c) at (4,1/4) {};
            
            \draw[densely dashed] (a) -- (a |- b);
            \draw[green!50!black] (a |- b) -- (b) node[pos=.33, below] {$x_r$};
                    
            \draw[densely dashed] (c) -- (b |- c);
            \draw[red] (b |- c) -- (b) node[pos=.33, left] {$y_r$};
        \end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容