绘制曲线,在轴上仅显示特定的符号值

绘制曲线,在轴上仅显示特定的符号值

我想要绘制如下曲线 (TTR=1-e^{-t}; t*=-log(0.2); TTR_PLATEAU=1):

在此处输入图片描述

到目前为止,我只知道如何在轴上显示一系列符号值。

\documentclass{article}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.15}
\usepackage{physics}
\usepackage{amsmath, amssymb, amsfonts}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
        xlabel={$t$},
        ylabel={$TTR$},
        axis lines=center,
        xtick distance=1,
        ytick distance=1,
        xmin=0,xmax=4.9,
        ymin=0,ymax=4.9,
        xticklabel={$t_{\pgfmathprintnumber[precision=0]{\tick}}$},
        yticklabel={$TTR_{\pgfmathprintnumber[precision=0]{\tick}}$}
]

\addplot +[mark=none,smooth] {1-e^(-x)};

\end{axis}
\end{tikzpicture}

\end{document}

太感谢了。

答案1

xtick/ytick用于在特定位置设置刻度,xticklabels/ yticklabelss末尾注释)用于提供标签列表(而不是像 那样提供模式xticklabel)。

代码输出

\documentclass{article}
\usepackage{pgfplots}% also loads graphicx
\pgfplotsset{width=10cm,compat=1.15}
\usepackage{physics}
\usepackage{amsmath, amssymb, amsfonts}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
        xlabel={$t$},
        ylabel={$TTR$},
        axis lines=center,
        xmin=0,xmax=4.9,
        ymin=0,ymax=4.9,
        ytick={0.8,1},
        xtick={1.61},
        xticklabels={$t^*$},
        yticklabels={80\% TTR\_PL, TTR\_PLATEAU}
]

\addplot +[mark=none,smooth] {1-e^(-x)};
\draw [dashed] (0,0.8) -| (1.61,0);
\draw [dashed] (0,1) -- (\pgfkeysvalueof{/pgfplots/xmax},1);

\end{axis}
\end{tikzpicture}

\end{document}

答案2

或者,通过使用intersections库:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.15}
\usetikzlibrary{intersections}
\usepackage{siunitx}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
        xlabel={$t$},
        ylabel={$TTR$},
        axis lines=center,
        ymin=0, ymax=2,
        xtick=\empty,
        ytick=\empty,
        no marks,
        every axis plot post/.append style={very thick},
        clip=false
]

\addplot +[name path=A,domain=0:5] {1-e^(-x)};
\path [name path=B] (0,0.8) -- + (5,0);
\draw [name intersections={of=A and B, by={a}}, dashed]
    (0,0.8) node[left] {\SI{80}{\%}TTR\_PL}  -| (a |- 0,0) node[below] {$t*$};
\draw[dashed] (0,1)node[left] {TTR\_PLATEAU} -- + (5,0);
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案3

为时已晚

在此处输入图片描述

\documentclass{article}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.15}
\usepackage{physics}
\usepackage{amsmath, amssymb, amsfonts}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    xlabel={$t$},
    ylabel={$TTR$},
    axis lines=center,
    xtick={\empty},
    ytick={\empty},
    xmin=0,xmax=4.9,
    ymin=0,ymax=4.9,
    extra x ticks={1.6,0},
    extra y ticks={0.75,1.2},
    extra x tick labels={$t^*$},
    extra y tick labels={$80\%$~TTR\_PL, TTR\_PLATEAU},
    no marks,
]
\addplot +[mark=none,smooth,ultra thick] {1-e^(-x)};
\addplot[thick,dashed,domain=0:5] {1};
\addplot[thick,dashed] coordinates {(1.6,0) (1.6,0.7981)};
\addplot[thick,dashed] coordinates {(0,0.7981) (1.6,0.7981)};

\end{axis}
\end{tikzpicture}

\end{document}

答案4

一种使用 MetaPost 及其操作员执行此操作的方法intersectionpoint,可能对它感兴趣。通过luamplib包集成到 LuaLaTeX 程序中。

\RequirePackage{luatex85}
\documentclass[border=3mm]{standalone}
\usepackage{luamplib}
    \mplibsetformat{metafun}
    \mplibtextextlabel{enable}
    \mplibnumbersystem{double}
\begin{document}
\begin{mplibcode}
    u = cm; v = 2cm; xmax = 4.9; ymax = 1.9; xstep = .1; 
    beginfig(1);
        % graph and intersection
        path graph; 
        graph = origin for t = xstep step xstep until xmax: .. (t, 1-exp(-t)) endfor;
        draw graph xyscaled (u, v) withcolor red;
        z = ((0, .8) -- (infinity, .8)) intersectionpoint graph;
        draw ((x, 0) -- z -- (0, y)) xyscaled (u, v) dashed evenly;
        draw (0, v) -- (xmax*u, v) dashed evenly;
        % Axes and labels
        drawarrow origin -- (xmax*u, 0);
        label.bot("$t^*$", (x*u, 0));
        label.bot("$t$", (xmax*u, 0));
        drawarrow origin -- (0, ymax*v);
        label.lft("\textsc{TTR\_PLATEAU}", (0, v));
        label.lft("\textsc{80~\%~TTR\_PL}", (0, .8v));
        label.lft("\textsc{TTR}", (0, ymax*v));
    endfig;
\end{mplibcode}
\end{document}

在此处输入图片描述

相关内容