Latex 上的实时动画情节

Latex 上的实时动画情节

我想创建一个与时间(秒)相关的实时动画图形

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\pgfplotsset{ every non boxed y axis/.append style={y axis line style=-}}
\scalebox{0.5}{
%\begin{document}
    \begin{tikzpicture}
    \begin{axis}[%
    width=1.8\linewidth,
    height=1.2\linewidth,
    grid
    ,xlabel=Time (s)
    ,ylabel=\%MVC
    ,legend style={nodes={scale=1.8, transform shape}, at={(0.8,0.9)},anchor=west}
    ,axis x line = bottom,axis y line = left
    ,%={0,20,...,100}
    ,ymin=46, ymax=72, % or enlarge y limits=upper
    xmin=-4,xmax=125]

        \addplot+[const plot,color=red, mark=triangle*,ultra thick] coordinates {

(   0.022531    ,   70.853  )
(   0.689273    ,   70.853  )
(   6.059073    ,   65.0723 )
(   9.898123    ,   65.0723 )
(   19.716823   ,   63.82   )
(   27.423133   ,   63.1938 )
(   28.424583   ,   63.1938 )
(   36.398153   ,   63.1938 )
(   74.194053   ,   63.13   )
(   100.309753  ,   63.098  )
(   122.049853  ,   63.0821 )


    } node[below=1.15cm,pos=.76,black] {};

    \addlegendentry{$\overline{F_i}$}



\addplot+[const plot, color=black, mark=square,ultra thick] coordinates {

(   0.022531    ,   58.9965 )
(   0.689273    ,   65.0723 )
(   6.059073    ,   62.182  )
(   9.898123    ,   63.82   )
(   19.716823   ,   63.1938 )
(   27.423133   ,   62.8808 )
(   28.424583   ,   63.0506 )
(   36.398153   ,   63.13   )
(   74.194053   ,   63.098  )
(   100.309753  ,   63.0821 )
(   122.049853  ,   63.0741 )



} node[below=1.15cm,pos=.76,black] {};

\addlegendentry{$F_{i}^{target}$}

    \addplot+[const plot,mark=*, color=green,ultra thick] coordinates {

(   0.022531    ,   47.1399 )
(   0.689273    ,   59.2917 )
(   6.059073    ,   59.2917 )
(   9.898123    ,   62.5677 )
(   19.716823   ,   62.5677 )
(   27.423133   ,   62.5677 )
(   28.424583   ,   62.9073 )
(   36.398153   ,   63.0661 )
(   74.194053   ,   63.0661 )
(   100.309753  ,   63.0661 )
(   122.049853  ,   63.0661 )


} node[below,pos=.57, black] {};

\addlegendentry{$\underline{F_i}$}

    \node[ultra thick, color=black] at (3.8,135.5) {\textbf{${F_0}^{target}$}};
\node[ultra thick, color=red] at (3.5,255) {\textbf{$\overline{F_0}$}};
\node[ultra thick, color=green, ultra thick] at (5.2,15) {\textbf{$\underline{F_0}^{SALBP-1}$}};

\draw [dashed, , thick] (5.2,12) -- (127,12);
\draw [>=stealth, <->] (126,12.2)--(126,169) node[midway,left, ultra thick] {$\overline{F_{10}}^{IDS}-\underline{F_0}^{SALBP-1}$};
    \end{axis}
    \end{tikzpicture}
}
\end{document}

有人可以帮忙吗?

答案1

由于时间以秒为单位,因此您可以通过以下方式将绘图限制在所需范围内:

\clip (-4,46) rectangle (\it,72);

\it时间计数器在哪里。您clip mode=individual需要将情节标记置于剪辑中。如果我对动画手册的理解正确的话,您需要 in1\begin{animateinline}[controls]{1}实现“实时”。

\documentclass{article}
\usepackage{animate}
%\usepackage[export]{animate}

\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}

\pgfplotsset{ every non boxed y axis/.append style={y axis line style=-}}
\begin{animateinline}[controls]{1}
  \multiframe{120}{it=0+1}{\scalebox{0.5}{
    \begin{tikzpicture}
    \begin{axis}[%
    width=1.8\linewidth,
    height=1.2\linewidth,
    grid
    ,xlabel=Time (s)
    ,ylabel=\%MVC
    ,legend style={nodes={scale=1.8, transform shape}, at={(0.8,0.9)},anchor=west,cells={anchor=west}}
    ,axis x line = bottom,axis y line = left
    ,ymin=46, ymax=72, % or enlarge y limits=upper
    xmin=-4,xmax=125,clip mode=individual]
\clip (-4,46) rectangle (\it,72);
        \addplot+[const plot,color=red, mark=triangle*,ultra thick] coordinates {

(   0.022531    ,   70.853  )
(   0.689273    ,   70.853  )
(   6.059073    ,   65.0723 )
(   9.898123    ,   65.0723 )
(   19.716823   ,   63.82   )
(   27.423133   ,   63.1938 )
(   28.424583   ,   63.1938 )
(   36.398153   ,   63.1938 )
(   74.194053   ,   63.13   )
(   100.309753  ,   63.098  )
(   122.049853  ,   63.0821 )


    } node[below=1.15cm,pos=.76,black] {};

    \addlegendentry{$\overline{F_i}$}



\addplot+[const plot, color=black, mark=square,ultra thick] coordinates {

(   0.022531    ,   58.9965 )
(   0.689273    ,   65.0723 )
(   6.059073    ,   62.182  )
(   9.898123    ,   63.82   )
(   19.716823   ,   63.1938 )
(   27.423133   ,   62.8808 )
(   28.424583   ,   63.0506 )
(   36.398153   ,   63.13   )
(   74.194053   ,   63.098  )
(   100.309753  ,   63.0821 )
(   122.049853  ,   63.0741 )



} node[below=1.15cm,pos=.76,black] {};

\addlegendentry{$F_{i}^\mathrm{target}$}

    \addplot+[const plot,mark=*, color=green,ultra thick] coordinates {

(   0.022531    ,   47.1399 )
(   0.689273    ,   59.2917 )
(   6.059073    ,   59.2917 )
(   9.898123    ,   62.5677 )
(   19.716823   ,   62.5677 )
(   27.423133   ,   62.5677 )
(   28.424583   ,   62.9073 )
(   36.398153   ,   63.0661 )
(   74.194053   ,   63.0661 )
(   100.309753  ,   63.0661 )
(   122.049853  ,   63.0661 )


} node[below,pos=.57, black] {};

\addlegendentry{$\underline{F_i}$}

    \node[ultra thick, color=black] at (3.8,135.5) {\textbf{${F_0}^{target}$}};
\node[ultra thick, color=red] at (3.5,255) {\textbf{$\overline{F_0}$}};
\node[ultra thick, color=green, ultra thick] at (5.2,15) {\textbf{$\underline{F_0}^{SALBP-1}$}};

\draw [dashed, , thick] (5.2,12) -- (127,12);
\draw [>=stealth, <->] (126,12.2)--(126,169) node[midway,left, ultra thick] {$\overline{F_{10}}^{IDS}-\underline{F_0}^{SALBP-1}$};
    \end{axis}
    \end{tikzpicture}
}}
\end{animateinline}
\end{document}

结果是一个可以用 Acrobat Reader 播放的动画。原则上我可以上传一个 gif,但 120 步太长了,无法在此处显示。但是,如果将步长增加到两秒,它就变得足够小,可以上传了。

\documentclass{standalone}
%\usepackage{animate}
\usepackage[export]{animate}

\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}

\pgfplotsset{ every non boxed y axis/.append style={y axis line style=-}}
\begin{animateinline}[controls]{1}
  \multiframe{60}{it=0+2}{\scalebox{0.5}{
    \begin{tikzpicture}
    \begin{axis}[%
    width=1.8\linewidth,
    height=1.2\linewidth,
    grid,legend style={cells={anchor=west}},
    ,xlabel=Time (s)
    ,ylabel=\%MVC
    ,legend style={nodes={scale=1.8, transform shape}, at={(0.8,0.9)},anchor=west}
    ,axis x line = bottom,axis y line = left
    ,ymin=46, ymax=72, % or enlarge y limits=upper
    xmin=-4,xmax=125,clip mode=individual]
\clip (-4,46) rectangle (\it,72);
        \addplot+[const plot,color=red, mark=triangle*,ultra thick] coordinates {

(   0.022531    ,   70.853  )
(   0.689273    ,   70.853  )
(   6.059073    ,   65.0723 )
(   9.898123    ,   65.0723 )
(   19.716823   ,   63.82   )
(   27.423133   ,   63.1938 )
(   28.424583   ,   63.1938 )
(   36.398153   ,   63.1938 )
(   74.194053   ,   63.13   )
(   100.309753  ,   63.098  )
(   122.049853  ,   63.0821 )


    } node[below=1.15cm,pos=.76,black] {};

    \addlegendentry{$\overline{F_i}$}



\addplot+[const plot, color=black, mark=square,ultra thick] coordinates {

(   0.022531    ,   58.9965 )
(   0.689273    ,   65.0723 )
(   6.059073    ,   62.182  )
(   9.898123    ,   63.82   )
(   19.716823   ,   63.1938 )
(   27.423133   ,   62.8808 )
(   28.424583   ,   63.0506 )
(   36.398153   ,   63.13   )
(   74.194053   ,   63.098  )
(   100.309753  ,   63.0821 )
(   122.049853  ,   63.0741 )



} node[below=1.15cm,pos=.76,black] {};

\addlegendentry{$F_{i}^\mathrm{target}$}

    \addplot+[const plot,mark=*, color=green,ultra thick] coordinates {

(   0.022531    ,   47.1399 )
(   0.689273    ,   59.2917 )
(   6.059073    ,   59.2917 )
(   9.898123    ,   62.5677 )
(   19.716823   ,   62.5677 )
(   27.423133   ,   62.5677 )
(   28.424583   ,   62.9073 )
(   36.398153   ,   63.0661 )
(   74.194053   ,   63.0661 )
(   100.309753  ,   63.0661 )
(   122.049853  ,   63.0661 )


} node[below,pos=.57, black] {};

\addlegendentry{$\underline{F_i}$}

    \node[ultra thick, color=black] at (3.8,135.5) {\textbf{${F_0}^{target}$}};
\node[ultra thick, color=red] at (3.5,255) {\textbf{$\overline{F_0}$}};
\node[ultra thick, color=green, ultra thick] at (5.2,15) {\textbf{$\underline{F_0}^{SALBP-1}$}};

\draw [dashed, , thick] (5.2,12) -- (127,12);
\draw [>=stealth, <->] (126,12.2)--(126,169) node[midway,left, ultra thick] {$\overline{F_{10}}^{IDS}-\underline{F_0}^{SALBP-1}$};
    \end{axis}
    \end{tikzpicture}
}}
\end{animateinline}
\end{document}

在此处输入图片描述

相关内容