3b1b / 3b1b/manim

Manim is not correctly drawing tikzpictures

未关闭
#1,209 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
LaTeX
主要语言
Python
星标
93.8k
派生
7.7k
PR 合并指标
PR 指标待抓取

描述

I'm very very new to coding and am mostly trying to learn on my own. I'm starting to pick up the basics of manim, but am still having difficulties with troubleshooting. I've been trying to get manim to draw tikz diagrams and I've spent hours digging through what seemed like similar issues. I finally got it to draw the diagram, but it's all messed up and I can't find any solutions online.

I'm trying to do a tree diagram. It should look like this (from LaTeX):

Screen Shot 2020-08-19 at 9 44 20 PM

Here's the code I used in manim:

```
from manimlib.imports import *

class TikzMobject(TextMobject):
CONFIG = {
"stroke_width": 3,
"fill_opacity": 0,
"stroke_opacity": 1,
}

class Tree(Scene):
def construct(self):


TreeDiagram = TikzMobject(r"""
\begin{tikzpicture}[level distance=5em,level 1/.style={sibling distance=5cm},level 2/.style={sibling distance=2.5cm},level 3/.style={sibling distance=1cm},every node/.style={shape=rectangle,rounded corners,draw,align=center}]]
\node {Start}
child { node {$s_1$}
child { node {$p_1$}
child { node{$f_1$}}
child { node{$f_2$}}}
child { node {$p_2$}
child { node{$f_1$}}
child { node{$f_2$}}}}
child { node {$s_2$}
child { node {$p_1$}
child { node {$f_1$}}
child { node {$f_2$}}}
child { node {$p_2$}
child { node {$f_1$}}
child { node {$f_2$}}}}
child { node {$s_3$}
child { node {$p_1$}
child { node {$f_1$}}
child { node {$f_2$}}}
child { node {$p_2$}
child { node {$f_1$}}
child { node {$f_2$}}}};
\end{tikzpicture}
""")
TreeDiagram.scale(0.3)
TreeDiagram.rotate(TAU/2)

self.play(FadeIn(TreeDiagram))
```

But what it produces is this:

Screen Shot 2020-08-19 at 9 48 02 PM

I would greatly appreciate any help!

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。