绘制截止图

绘制截止图

我怎样才能用 LaTeX 绘制这样的函数?

在此处输入图片描述

但是如果没有尖锐性(即平滑过渡)并且函数永远不会达到零,那该怎么办?

这是我的代码:

\begin{figure}[H]

\centering
  \begin{tikzpicture}
  \begin{axis}[
      xmin=0, xmax=1,
      xtick=\empty, % remove all ticks from x-axis
      ytick={0,1}, % remove all ticks from y-axis
      xlabel=$\ \ \ \ \ \ \ \ \ \ \  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  t_{mix}(\varepsilon)  \ \   \  \ \ \ \ \ \ \ \ \ \ \ \ \ \ t$, 
      ylabel=\empty,
      axis lines=left, % default is to make a box around the axis
      samples = 100,
      domain=0:5,
      restrict y to domain=-0:1,
      legend pos=north east
      ]
    \addplot [black, samples = 100] {(x<0.638585)*(1 - exp(7*x)/100) + (!(x<0.638585))*(exp(-7* (x - 0.5))/3)};
    \addlegendentry{$d(t)$}
    \addplot [green, samples = 100] {(4)^(-1)};
    \addlegendentry{$\varepsilon$}
    \draw [dashed] (0.61678,-1) -- (0.61678,1);
  \end{axis}
  \end{tikzpicture}
\end{figure}

答案1

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
      xmin=0, xmax=1,
      ymin=0, ymax=1.05,
      xtick={ln(75)/7},
      xticklabels={$t_{mix}(\varepsilon)$},
      ytick=\empty,
      xlabel={$t$},
      x label style={at={(axis description cs:1,0)}},      
      axis lines=left,
]
\addplot[samples = 500, smooth] {x<0.63?(1-exp(7*x)/100):(exp(-20*(x-0.545)))};
\addlegendentry{$d(t)$}
\addplot[green, samples=2] {1/4};
\addlegendentry{$\varepsilon$}
\draw[dashed] ({ln(75)/7},0) -- (({ln(75)/7},1);
\end{axis}
\end{tikzpicture}
\end{document}

图形

答案2

这只是一个改进的版本hpekristiansen 的回答这对于评论来说太长了。

答案的主要“问题”是,这样计算的点数太多了。如您所见,仅用 25 个点(而不是 500 个点)就可以得到相同的结果。有关更多详细信息,请查看代码中的注释。

% used PGFPlots v1.18.1
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xmin=0, xmax=1,
        ymin=0, ymax=1.05,
        xtick={ln(75)/7},
        % ("mix" should be upright)
        xticklabels={$t_{\mathrm{mix}}(\varepsilon)$},
        ytick=\empty,
        xlabel={$t$},
        % (even better coordinate system to choose to place the `xlabel`)
        x label style={at={(xticklabel* cs:1)}},
        axis lines=left,
        % ---------------------------------------------------------------------
        % moved common stuff here
        % ---------------------------------------------------------------------
        smooth,
        % only this `domain` is shown, so no need to calculate the default
        % `domain` which is from -5 to +5 ...
        domain=0:1,
        % ... with that the default number of `samples` (25) is enough
        % to have a `smooth` plot (when `smooth` is used as well)
%        samples=25,
        % don't show any markers
        no markers,
        % ---------------------------------------------------------------------
    ]
        \addplot {x<0.63 ? 1-exp(7*x)/100 : exp(-20*(x-0.545))};
            \addlegendentry{$d(t)$}
        \addplot [green, samples=2] {1/4};
            \addlegendentry{$\varepsilon$}
        \draw[dashed] ({ln(75)/7},0) -- ({ln(75)/7},1);
    \end{axis}
\end{tikzpicture}
\end{document}

该图显示了上述代码的结果

相关内容