graphing_objects¶
- class Table[source]¶
Simplify creation and decoration of tables in Manim, with optional dictionary loading and styling.
This class supports manual content input (a list of table rows) or dictionary-based loading of structured content (e.g., mathematical expressions). It offers extensive customization options, including color themes, corner radii, decorative borders, and row highlighting.
- Parameters:
content (list[list] or str) – Table content as a list of rows (each row is a list of elements), or a dictionary key.
dictionary (str, optional) – Optional path to a dictionary file for loading content. If
"data_base", uses the built-in Beanim table dictionary.highlight_top (str) – Whether to highlight the top row. Use
"yes"(default) to enable.text_size (float) – Font size for each table cell. Default is
55.text_color (ParsableManimColor) – Color of text in the table. Default is
WHITE.decorator_presence (str) – Type of decoration to apply. Use
"box"to wrap content in a frame.decorator_color (ParsableManimColor) – Primary color for the decorator. Default is
WHITE.decorator_color_2 (ParsableManimColor) – Highlight color for top row cell 1. Default is
RED.decorator_color_3 (ParsableManimColor) – Highlight color for top row cell 2. Default is
BLUE.decorator_color_4 (ParsableManimColor) – Highlight color for top row cell 3. Default is
GREEN.decorator_stroke_width (float) – Stroke width for decorator borders. Default is
1.corner_rad (float) – Corner radius for decorator boxes. Default is
0.1.corner_rad_direction (list[int]) – List of four ints controlling which corners are rounded: [top-left, top-right, bottom-right, bottom-left]. Default is
[1, 1, 1, 1].fill_opa (float) – Fill opacity for decorative backgrounds. Default is
0.1.h_tightness (float) – Horizontal padding inside table cells. Default is
0.5.v_tightness (float) – Vertical padding inside table cells. Default is
0.5.tightness (float) – Padding around the decorator box. Default is
0.stroke_opa (float) – Opacity of table/border strokes. Default is
1.kwargs – Additional keyword arguments passed to
VGroup.
Note
When using dictionary content, the dictionary file should map keys to row data lists. See
handle_with_dictionary()for details.Example usage:
from manim import * from manim_beanim import Table class Example_Table(Scene): def construct(self): table1 = Table(content=[["1", "2"], ["3", "4"]]) table2 = Table(content="table_key", dictionary="data_base") self.add(VGroup(table1, table2).arrange(DOWN))
- add_decorator(mobject)[source]¶
Add decorators (highlight row and optional box) around the table.
This method first calls
add_highlight_top_row(), then wraps the table in a box ifdecorator_presence == "box".
- add_highlight_top_row()[source]¶
Highlight the top row of the table using specified decorator colors.
- check_file_exists(directory, filename)[source]¶
Check if a file exists in the given directory.
- Parameters:
directory (str or Path) – Directory path to check.
filename (str) – Filename to look for.
- Returns:
True if the file exists, False otherwise.
- Return type:
bool
Example:
>>> self.check_file_exists("path/to/dir", "file.txt") True
- filter_type()[source]¶
Determine the top row data regardless of content type.
- Returns:
The first row of the table content.
- Return type:
list
- handle_no_dictionary()[source]¶
Render table directly from manually provided content.
Creates a
MathTablefrom the provided content list and applies decoration.- Calls:
- handle_with_dictionary(dic_in_data_base)[source]¶
Render table by loading content from a dictionary file.
If
dictionary == "data_base", uses the built-in table dictionary. Otherwise loads from the provided path, splits directory and filename, and then constructs aMathTablefrom the retrieved data.- Parameters:
dic_in_data_base (str) – Base name for built-in dictionary files.
- load_dictionary()[source]¶
Load and parse a dictionary file containing table data.
- Returns:
Parsed dictionary mapping content keys to table rows.
- Return type:
dict
- split_dictionary_path(input_string)[source]¶
Split a path string at the last slash into directory and filename.
- Parameters:
input_string (str) – The full path to split.
- Returns:
[directory, filename]
- Return type:
list[str]
Example:
>>> self.split_dictionary_path("path/to/file.txt") ['path/to', 'file.txt']