将TikZ动画与ggplot动画相结合

时间:2016-07-26 10:00:26

标签: r animation markdown sweave tikz

我正在尝试重新创建this animation。我想要的是TikZ中的机械系统和R / ggplot中的图。最后,我希望在演示文稿中使用所有这些,最好是在R markdown / sweave演示文稿中。

这甚至可能吗?

到目前为止,我所拥有的是机械系统的TikZ:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, patterns, decorations.pathmorphing, decorations.markings}

\begin{document}
    \tikzstyle{blocksmall} = [draw, rectangle, minimum height = 0.25cm, minimum width = 0.25cm]
    \tikzstyle{block} = [draw, rectangle, minimum height = 1cm, minimum width = 2cm]
    \tikzstyle{spring} = [decorate, decoration = {zigzag, pre length = 0.3cm, post length = 0.3cm, segment length = 6}]
    \tikzstyle{ground} = [fill, pattern = north east lines, draw = none, minimum width = 0.75cm, minimum height = 0.3cm]
    \begin{tikzpicture}
        \node [blocksmall] (u) {$u$};
        \node [block, right of = u, node distance = 3cm] (m) {$m$};
        \node (ground) [ground, anchor = north, yshift = -0.25cm, xshift = 0cm, minimum width = 7cm] at (m.south) {};
        \draw (ground.north east) -- (ground.north west);
        \draw (m.south west) ++ (0.4cm,-0.125cm) circle (0.125cm)  (m.south east) ++ (-0.4cm,-0.125cm) circle (0.125cm);
        \draw [spring] (u) -- node[auto, yshift = 0.15cm] {$k$} (m);
    \end{tikzpicture}
\end{document}

编辑1:我发现此动画是使用Raphael.js和自定义linear.js完成的。然后将所有内容合并到freq.html

1 个答案:

答案 0 :(得分:0)

it might be to late but just to mention one possible solution for the future:

In the current development version of TikZ there is a new animation library that can be used to produce animated SVGsDocumentation of the animations-library. Maybe this information could help you. I don't know how to use the tool and what it is able to, but I already saw a beamer presentation using this library for animated graphs. It seemed to work well.