
データポイントを含む tikz 画像があります (一部のみ表示)
\documentclass{article}
\usepackage{pgfplots}
\newlength\figureheight
\newlength\figurewidth
\setlength{\figurewidth}{8cm}
\setlength{\figureheight}{4.5cm}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
/pgf/number format/.cd,
use comma,
1000 sep={},
width=0.951\figurewidth,
height=\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=-1,
xmax=1,
xlabel style={font=\color{white!15!black}},
xlabel={xlabel},
ymin=0,
ymax=1,
ylabel style={font=\color{white!15!black}},
ylabel={ylabel},
axis background/.style={fill=white}
]
\addplot [color=black, forget plot]
table[row sep=crcr]{%
-1 0\\
-0.987 0.001\\
-0.823 0.15\\
-0.713 0.4\\
-0.684 0.5\\
-0.542 0.6\\
-0.478 0.65\\
-0.3544 0.7\\
-0.254 0.8\\
-0.14 0.9\\
0 1\\
0.057774545 0.9\\
0.15794 0.8\\
0.258105455 0.7\\
0.358270909 0.65\\
0.458436364 0.6\\
0.558601818 0.5\\
0.658767273 0.4\\
0.758932727 0.15\\
0.859098182 0.05\\
0.959263636 0.001\\
1 0\\
};
\end{axis}
\end{tikzpicture}
\end{document}
データは測定値から生成され、単一の関数で(簡単に)適合させることはできません。少なくとも私はそれを避けたいと思います。
データを段階的に、または n ポイント単位でアニメーション化 (折れ線グラフ化) する良い方法はありますか?
手動で生成するのは避けたい
画像-01
\addplot [color=black, forget plot]
table[row sep=crcr]{%
-1 0\\
%-0.987 0.001\\
%-0.823 0.15\\
%-0.713 0.4\\
%-0.684 0.5\\
%-0.542 0.6\\
...
};
画像-02
\addplot [color=black, forget plot]
table[row sep=crcr]{%
-1 0\\
-0.987 0.001\\
%-0.823 0.15\\
%-0.713 0.4\\
%-0.684 0.5\\
%-0.542 0.6\\
...
};
それらの画像をループさせるには、自動化されたソリューションが望ましいです。
この情報が違いを生むのであれば、beamer クラスを使用して XeLaTeX でコンパイルします。
答え1
beamer
オンボードツールを使用したアニメーション:
選択マクロは以下から借用しましたhttps://tex.stackexchange.com/a/199396/36296
\documentclass{beamer}
\usepackage{pgfplots}
\newlength\figureheight
\newlength\figurewidth
\setlength{\figurewidth}{8cm}
\setlength{\figureheight}{4.5cm}
% Style to select only points from #1 to #2 (inclusive)
\pgfplotsset{select coords between index/.style 2 args={
x filter/.code={
\ifnum\coordindex<#1\def\pgfmathresult{}\fi
\ifnum\coordindex>#2\def\pgfmathresult{}\fi
}
}}
\makeatletter
\newcommand{\slide}{\the\beamer@slideinframe}
\makeatother
\begin{document}
\begin{frame}
\animate<1-22>
\transduration<1-22>{0.5}
\begin{tikzpicture}
\begin{axis}[%
/pgf/number format/.cd,
use comma,
1000 sep={},
width=0.951\figurewidth,
height=\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=-1,
xmax=1,
xlabel style={font=\color{white!15!black}},
xlabel={xlabel},
ymin=0,
ymax=1,
ylabel style={font=\color{white!15!black}},
ylabel={ylabel},
axis background/.style={fill=white}
]
\addplot [color=black, forget plot,select coords between index={0}{\slide}]
table[row sep=crcr]{%
-1 0\\
-0.987 0.001\\
-0.823 0.15\\
-0.713 0.4\\
-0.684 0.5\\
-0.542 0.6\\
-0.478 0.65\\
-0.3544 0.7\\
-0.254 0.8\\
-0.14 0.9\\
0 1\\
0.057774545 0.9\\
0.15794 0.8\\
0.258105455 0.7\\
0.358270909 0.65\\
0.458436364 0.6\\
0.558601818 0.5\\
0.658767273 0.4\\
0.758932727 0.15\\
0.859098182 0.05\\
0.959263636 0.001\\
1 0\\
};
\end{axis}
\end{tikzpicture}
\pause[20]
\end{frame}
\end{document}
答え2
これは表のデータポイントのアニメーションです。アニメーションにはanimate
-パッケージ。
\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{animate}
\usepackage{tikz}
\begin{filecontents}{mydata.data}
X Y
0 2
1 4
2 2
3 5
4 4
5 1
\end{filecontents}
\begin{document}
\begin{animateinline}{2}% frames per second
\multiframe{5}{ix=1+1}{% the +1 is the step size
\begin{tikzpicture}
\begin{axis}[
xlabel={X-Name},
ylabel={Y-Name},
xmin=0, xmax=5,
ymin=1, ymax=5,
]
\addplot[restrict x to domain=0:\ix,red] table [x index=0,y index=1]{mydata.data};
\end{axis}
\end{tikzpicture}
}
\end{animateinline}
\end{document}
結果は次のとおりです (アニメーションの開始ビューと終了ビュー):
アニメ化の要件:
- pdfTEX、バージョン 1.20 以上、または直接 PDF 出力用の LuaTEX
- PS から PDF への変換には Ghostscript、バージョン 9.15 以上または Adobe Distiller が必要です。
- DVI から PDF への変換には、dvipdfmx、バージョン >= 20080607 が必要です。
- Acrobat Reader(バージョン7以上)、PDF-XChange、Foxit Reader
編集:
後で画像をループするには、-package:loop
のオプションを設定できます。animate
\usepackage[loop]{animate}
答え3
OPは標準を使用しているのでarticle
クラスは のステップ機能を提供しませんがbeamer
、この例ではanimate
パッケージを使用して単一のドキュメント ページにアニメーション グラフを作成します (samcarter のコードを若干変更して使用)。
\documentclass{article}
\usepackage{pgfplots}
\usepackage{animate}
\newlength\figureheight
\newlength\figurewidth
\setlength{\figurewidth}{8cm}
\setlength{\figureheight}{4.5cm}
% Style to select only points from #1 to #2 (inclusive)
\pgfplotsset{select coords between index/.style 2 args={
x filter/.code={
\ifnum\coordindex<#1\def\pgfmathresult{}\fi
\ifnum\coordindex>#2\def\pgfmathresult{}\fi
}
}}
\begin{document}
\begin{animateinline}[controls]{2} % 2 frames per sec
\multiframe{22}{idx=1+1}{ % 22 frames for 22 line segments
\begin{tikzpicture} % idx=1, 2, ..., 22
\begin{axis}[%
/pgf/number format/.cd,
use comma,
1000 sep={},
width=0.951\figurewidth,
height=\figureheight,
at={(0\figurewidth,0\figureheight)},
scale only axis,
xmin=-1,
xmax=1,
xlabel style={font=\color{white!15!black}},
xlabel={xlabel},
ymin=-0.1,
ymax=1,
ylabel style={font=\color{white!15!black}},
ylabel={ylabel},
axis background/.style={fill=white}
]
\addplot [
color=black, forget plot,select coords between index={0}{\idx},
unbounded coords=jump
] table[row sep=crcr]{%
-1 0\\
-0.987 0.001\\
-0.823 0.15\\
-0.713 0.4\\
-0.684 0.5\\
-0.542 0.6\\
-0.478 0.65\\
-0.3544 0.7\\
-0.254 0.8\\
-0.14 0.9\\
0 1\\
0.057774545 0.9\\
0.15794 0.8\\
0.258105455 0.7\\
0.358270909 0.65\\
0.458436364 0.6\\
0.558601818 0.5\\
0.658767273 0.4\\
0.758932727 0.15\\
0.859098182 0.05\\
0.959263636 0.001\\
1 0\\
};
\end{axis}
\end{tikzpicture}
}
\end{animateinline}
\end{document}