我得到了以下代码:
\documentclass[tikz,border=2pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\usepackage{animate}
\usepackage{fp}
\newcommand*\tdist[1]{
\begin{tikzpicture}
\begin{axis}[%
xlabel =$q$,
ylabel =$d$,
xtick={-6,-4,...,6},ytick={.05,.1,...,.45},
height=7cm, width=7cm,
axis lines*=left,
xmin = -6, xmax = 6,
ymin = 0, ymax = .41,
every y tick label/.append style =
{
/pgf/number format/.cd,
precision = 2,
fixed zerofill,
fixed
},/pgf/number format/.cd,
use comma]
\def\k{#1}
\addplot+[mark={},very thick, draw=cyan!80] gnuplot[raw gnuplot] {%
plot [-6:6][-6:6] gamma(.5*(\k+1))/(sqrt(\k*pi)*gamma(.5*\k))*((1+x^2/\k)^(-.5*(\k+1)))};
\end{axis}
\end{tikzpicture}
}
\begin{document}
\begin{animateinline}[controls,loop,palindrome]{12}
\multiframe{72}{k=0+20}{
\tdist{\k}
}
\end{animateinline}
\end{document}
它编译成功,没有错误,但完全占用了一个 CPU 核心,并且永远无法完成。出了什么问题?
答案1
移至包加载格式。使用tikz
时不要将 tikz 放在类选项中。由于涉及 gnuplot,请使用 xelatex -shellescape (MiKteX) 进行编译。另请参阅此处的信息standalone
动画中缺少端基
代码
\documentclass[border=2pt]{standalone}
\usepackage{tikz,pgfplots}
\usetikzlibrary{calc}
\usepackage{animate}
\usepackage{fp}
\newcommand*\tdist[1]{
\begin{tikzpicture}
\begin{axis}[%
xlabel =$q$,
ylabel =$d$,
xtick={-6,-4,...,6},ytick={.05,.1,...,.45},
height=7cm, width=7cm,
axis lines*=left,
xmin = -6, xmax = 6,
ymin = 0, ymax = .41,
every y tick label/.append style =
{
/pgf/number format/.cd,
precision = 2,
fixed zerofill,
fixed
},/pgf/number format/.cd,
use comma]
\def\k{#1}
\addplot+[mark={},very thick, draw=cyan!80] gnuplot[raw gnuplot] {%
plot [-6:6][-6:6] gamma(.5*(\k+1))/(sqrt(\k*pi)*gamma(.5*\k))*((1+x^2/\k)^(-.5*(\k+1)))};
\end{axis}
\end{tikzpicture}
}
\begin{document}
\begin{animateinline}[controls,loop,poster=last]{12}
\multiframe{72}{ik=0+1}{
\tdist{\ik}
}
\end{animateinline}
\end{document}