自定义轴的划分

自定义轴的划分

我正在尝试用一些点之间的长度的自定义指示器替换 x 轴上的刻度。像这样:

样本

到目前为止,除了更换蜱虫之外,我什么都能做。

\begin{tikzpicture}
    \begin{axis}
    [
    title = {Ekick Electrode Voltage},
    axis lines = middle,
    ylabel near ticks,
    xlabel near ticks,
    axis x line*=bottom,
    ymin = -80,
    ymax = -17,
    ylabel = {Voltage~[V]},
    xmajorticks=false
    ]
    \addplot[thick, blue, domain=0:10e-9, samples=100]  {(43) * pow(1 + exp(-(x - 10e-9 / 2) * 4.5 * 2 / 10e-9), -1) - 70};
    \addplot[thick, blue, domain=10e-9:30e-9, samples=100]  {-27};
    \addplot[thick, blue, domain=40e-9:45e-9, samples=100, ->]  {-70};
    \addplot[thick, blue, domain=30e-9:40e-9, samples=100]  {(-43) * pow(1 + exp(-((x - 30e-9) - 10e-9 / 2) * 4.5 * 2 / 10e-9), -1) - 27};
    \addplot[thick, dashed, samples=50] coordinates {(10e-9,-85)(10e-9,-20)};
    \addplot[thick, dashed, samples=50] coordinates {(30e-9,-85)(30e-9,-20)};
    \addplot[thick, dashed, samples=50] coordinates {(40e-9,-85)(40e-9,-20)};
    \end{axis}
    \end{tikzpicture}

有人能告诉我如何才能实现这个目标吗?

谢谢。

答案1

一种方法是使用垂直虚线图来定义可用于轴环境之外的注释的符号坐标。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[title = {Ekick Electrode Voltage},
    axis lines = middle,
    ylabel near ticks,
    xlabel near ticks,
    axis x line*=bottom,
    ymin = -80,
    ymax = -17,
    ylabel = {Voltage~[V]},
    xmajorticks=false
    ]
    \addplot[thick, blue, domain=0:10e-9, samples=100]  {(43) * pow(1 + exp(-(x - 10e-9 / 2) * 4.5 * 2 / 10e-9), -1) - 70};
    \addplot[thick, blue, domain=10e-9:30e-9, samples=100]  {-27};
    \addplot[thick, blue, domain=40e-9:45e-9, samples=100, ->]  {-70};
    \addplot[thick, blue, domain=30e-9:40e-9, samples=100]  {(-43) * pow(1 + exp(-((x - 30e-9) - 10e-9 / 2) * 4.5 * 2 / 10e-9), -1) - 27};
    \addplot[thick, dashed, samples=2] coordinates {(10e-9,-85)(10e-9,-20)}
        coordinate (p1);
    \addplot[thick, dashed, samples=2] coordinates {(30e-9,-85)(30e-9,-20)}
        coordinate (p2);
    \addplot[thick, dashed, samples=2] coordinates {(40e-9,-85)(40e-9,-20)}
        coordinate (p3);
    \path (0,0) coordinate (p0);    
 \end{axis}
 \path ([yshift=-1em]current axis.south) coordinate (l);
 \begin{scope}[>=latex,<->,shorten >=0.2pt,shorten <=0.2pt,
    nodes={text height=1.4ex}]
  \draw (p0|-l) -- (p1|-l) node[midway,below]{$10\,$ms};
  \draw (p1|-l) -- (p2|-l) node[midway,below]{Delay Time};
  \draw (p2|-l) -- (p3|-l) node[midway,below]{$10\,$ms};
 \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

不过,我认为还需要修复蓝色图。这可以通过绘制一个图并将其用于tanh平滑步骤来实现。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[title = {Ekick Electrode Voltage},
    axis lines = middle,
    ylabel near ticks,
    xlabel near ticks,
    axis x line*=bottom,
    ymin = -80,
    ymax = -17,
    ylabel = {Voltage~[V]},
    xmajorticks=false,
    declare function={x1=10e-9;x2=30e-9;x3=40e-9;x4=45e-9;y1=-70;y2=-27;}
    ]
    \addplot[thick, blue, domain=0:x4, samples=101,-stealth]  
    {y1+ (y2-y1)*(1/2+tanh(6*(x-x1/2)/x1)/2) 
       + (y1-y2)*(1/2+tanh(6*(x-x2/2-x3/2)/x1)/2)};
    \addplot[thick, dashed, samples=2] coordinates {(x1,-85)(x1,-20)}
        coordinate (p1);
    \addplot[thick, dashed, samples=2] coordinates {(x2,-85)(x2,-20)}
        coordinate (p2);
    \addplot[thick, dashed, samples=2] coordinates {(x3,-85)(x3,-20)}
        coordinate (p3);
    \path (0,0) coordinate (p0);    
 \end{axis}
 \path ([yshift=-1em]current axis.south) coordinate (l);
 \begin{scope}[>=latex,<->,shorten >=0.2pt,shorten <=0.2pt,
    nodes={text height=1.4ex}]
  \draw (p0|-l) -- (p1|-l) node[midway,below]{$10\,$ms};
  \draw (p1|-l) -- (p2|-l) node[midway,below]{Delay Time};
  \draw (p2|-l) -- (p3|-l) node[midway,below]{$10\,$ms};
 \end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容