3

I'm defining some functions to plot using pgfplots and that has been successful. Now I would like to add a y tick at a point that's evaluated using these functions (lbound below). I can't seem to be able to use lbound as a constant however. This is to mark the point where the horizontal plot hits the y-axis. What should I do instead?

\begin{tikzpicture}[
    declare function={
        tmin = 0;
        tmax = 1;
        C(\x) = (\x)^2;
        Cinv(\x) = (\x)^(1/2);
        ell(\theta,\tau,\K) = 1 - Cinv( (- (\tau * \theta) / (tmax - tmin) + \K) );
        lbound = ell(1, 0.8, C(1) + 0.8 * tmin / (tmax - tmin));
  }
    ]

    \begin{axis}[
            ytick={0,1},
            yticklabels={$0$,$1$}
            ]
        \addplot[dashed, thick, domain=0:1]{ell(1, 0.8, C(1) + 0.8 * tmin / (tmax - tmin))};
    \end{axis}
\end{tikzpicture}
4

1 回答 1

2

我可能会误解这个问题,但阅读它的一种方法是你想要这个:

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}[
    declare function={
        tmin = 0;
        tmax = 1;
        C(\x) = (\x)^2;
        Cinv(\x) = (\x)^(1/2);
        ell(\theta,\tau,\K) = 1 - Cinv( (- (\tau * \theta) / (tmax - tmin) + \K) );
        lbound = ell(1, 0.8, C(1) + 0.8 * tmin / (tmax - tmin));
  }
    ]

    \begin{axis}[
            ytick={0,lbound},
            yticklabels={$0$,$\ell_\mathrm{bound}$}
            ]
        \addplot[dashed, thick, domain=0:1]{ell(1, 0.8, C(1) + 0.8 * tmin / (tmax - tmin))};
    \end{axis}
\end{tikzpicture}
\end{document}

在此处输入图像描述

于 2020-04-26T06:55:43.443 回答