You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Manim的MathTable中设置所有单元格尺寸为(2,1)

Manim中设置MathTable单元格尺寸为(2,1)的方法

要给MathTable的所有单元格统一设置尺寸为(2,1),直接在创建MathTable对象时传入cell_size参数即可,该参数接受一个元组(宽度, 高度)。另外注意你代码里的导入语句有误,正确的Manim导入方式是from manim import *。

修改后的完整代码如下:

from manim import *

class Scene(Scene):
    def construct(self):
        quarks = MathTable(
            [
                ["u", "c", "t"],
                ["d", "s", "b"],
            ],
            include_outer_lines=True,
            cell_size=(2, 1)  # 设置所有单元格宽2、高1
        )

        self.play(Create(quarks))

如果后续需要单独调整某几个单元格的尺寸,可以通过get_cell方法定位目标单元格后,调用set_width和set_height单独修改,但统一设置所有单元格时,cell_size参数是最简便的方案。

内容的提问来源于stack exchange,提问作者Ayrton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 05:07:23