顶点不规则图形

顶点不规则图形

在此处输入图片描述

请帮助我克服这个问题:情节不是静止的。

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage[export]{animate}
\usepackage[output-decimal-marker={,}]{siunitx}

\begin{document}

\begin{animateinline}[poster=last,autoplay,loop]{5} 
\multiframe{51}{rt=0.0+0.2}{% 
\resizebox{0.5\textwidth}{!}{%
\begin{tikzpicture}[shift={(1,1)},x=1cm, y=1cm]
\begin{axis}[ 
    x=1cm, y=0.1cm,
    anchor=target,
    enlargelimits=0.05,
    axis x line = center,
    axis y line = left,
    axis line style={line width=2pt,->,opacity=1},
    ymin=0,
    ymax=110,
    xmin=0,
    xmax=12,
    clip mode=individual,
    axis x line=bottom,
    axis y line=left,
    xtick={0,2,...,10},
    ytick={0,20,...,100},
    ticklabel style={font=\normalsize,opacity=1},
    xlabel={$t/\si{s}$},
    ylabel={$x/\si{m}$},
    y tick label style={
        /pgf/number format/.cd,
        fixed,
        fixed zerofill,
        precision=1,
    use comma,
        /tikz/.cd },
    x tick label style={
        /pgf/number format/.cd,
        fixed,
        fixed zerofill,
        precision=1,
    use comma,
        /tikz/.cd },
    every axis x label/.style={
    at={(ticklabel* cs:1)},
    anchor=north east,
    style={font=\normalsize},
    opacity=1  },
    every axis y label/.style={
    at={(ticklabel* cs:1)},
    anchor=north east,
    style={font=\normalsize},
    opacity=1  },
]
\addplot[blue,no marks,domain =0:\rt] plot gnuplot{%
x>0.0       &&  x<=4.0   ?  10.0*x             : %
x>4.0       &&  x<=6.0   ?  40.0               : %
x>6.0       &&  x<=10.0  ?  100.0 - 10.0*x     : %
1:0};
\node[coordinate] (target) at (axis cs:0,0){};

\end{axis}
\end{tikzpicture}}}  
\end{animateinline}

\end{document}

答案1

样本不是在您想要的点处采集的。您还需要x>=0.0而不是x>0.0。如果您将样本设置为 为步数,则得到

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage[export]{animate}
\usepackage[output-decimal-marker={,}]{siunitx}

\begin{document}

\begin{animateinline}[poster=last,autoplay,loop]{5} 
\multiframe{51}{rt=0.0+0.2}{% 
\resizebox{0.5\textwidth}{!}{%
\begin{tikzpicture}[shift={(1,1)},x=1cm, y=1cm]
\begin{axis}[ 
    x=1cm, y=0.1cm,
    anchor=target,
    enlargelimits=0.05,
    axis x line = center,
    axis y line = left,
    axis line style={line width=2pt,->,opacity=1},
    ymin=0,
    ymax=110,
    xmin=0,
    xmax=12,
    clip mode=individual,
    axis x line=bottom,
    axis y line=left,
    xtick={0,2,...,10},
    ytick={0,20,...,100},
    ticklabel style={font=\normalsize,opacity=1},
    xlabel={$t/\si{s}$},
    ylabel={$x/\si{m}$},
    y tick label style={
        /pgf/number format/.cd,
        fixed,
        fixed zerofill,
        precision=1,
    use comma,
        /tikz/.cd },
    x tick label style={
        /pgf/number format/.cd,
        fixed,
        fixed zerofill,
        precision=1,
    use comma,
        /tikz/.cd },
    every axis x label/.style={
    at={(ticklabel* cs:1)},
    anchor=north east,
    style={font=\normalsize},
    opacity=1  },
    every axis y label/.style={
    at={(ticklabel* cs:1)},
    anchor=north east,
    style={font=\normalsize},
    opacity=1  },
]
\pgfmathtruncatemacro{\mysamples}{\rt*5+1.001}
\addplot[blue,no marks,domain =0:\rt,samples=\mysamples] plot gnuplot{%
x>=0.0       &&  x<=4.0   ?  10.0*x             : %
x>4.0       &&  x<=6.0   ?  40.0               : %
x>6.0       &&  x<=10.0  ?  100.0 - 10.0*x     : %
1:0};
\node[coordinate] (target) at (axis cs:0,0){};

\end{axis}
\end{tikzpicture}}}  
\end{animateinline}

\end{document}

在此处输入图片描述

相关内容