A newer version of the Gradio SDK is available: 6.20.0
Matrix
Qualified name: manim.mobject.matrix.Matrix
class Matrix(matrix, v_buff=0.8, h_buff=1.3, bracket_h_buff=0.25, bracket_v_buff=0.25, add_background_rectangles_to_entries=False, include_background_rectangle=False, element_to_mobject=<class 'manim.mobject.text.tex_mobject.MathTex'>, element_to_mobject_config={}, element_alignment_corner=array([ 1., -1., 0.]), left_bracket='[', right_bracket=']', stretch_brackets=True, bracket_config={}, **kwargs)
Bases: VMobject
A mobject that displays a matrix on the screen.
- Parameters:
- matrix (Iterable) β A numpy 2d array or list of lists.
- v_buff (float) β Vertical distance between elements, by default 0.8.
- h_buff (float) β Horizontal distance between elements, by default 1.3.
- bracket_h_buff (float) β Distance of the brackets from the matrix, by default
MED_SMALL_BUFF. - bracket_v_buff (float) β Height of the brackets, by default
MED_SMALL_BUFF. - add_background_rectangles_to_entries (bool) β
Trueif should add backgraound rectangles to entries, by defaultFalse. - include_background_rectangle (bool) β
Trueif should include background rectangle, by defaultFalse. - element_to_mobject (type *[*Mobject ] | Callable *[* *...* *,* Mobject ]) β The mobject class used to construct the elements, by default
MathTex. - element_to_mobject_config (dict) β Additional arguments to be passed to the constructor in
element_to_mobject, by default{}. - element_alignment_corner (Sequence *[*float ]) β The corner to which elements are aligned, by default
DR. - left_bracket (str) β The left bracket type, by default
"[". - right_bracket (str) β The right bracket type, by default
"]". - stretch_brackets (bool) β
Trueif should stretch the brackets to fit the height of matrix contents, by defaultTrue. - bracket_config (dict) β Additional arguments to be passed to
MathTexwhen constructing the brackets. - kwargs (Any)
Examples
The first example shows a variety of uses of this module while the second example exlpains the use of the options add_background_rectangles_to_entries and include_background_rectangle.
Methods
add_background_to_entries |
Add a black background rectangle to the matrix, see above for an example. |
|---|---|
get_brackets |
Return the bracket mobjects. |
get_columns |
Return columns of the matrix as VGroups. |
get_entries |
Return the individual entries of the matrix. |
get_mob_matrix |
Return the underlying mob matrix mobjects. |
get_rows |
Return rows of the matrix as VGroups. |
set_column_colors |
Set individual colors for each columns of the matrix. |
set_row_colors |
Set individual colors for each row of the matrix. |
Attributes
animate |
Used to animate the application of any method of self. |
|---|---|
animation_overrides |
|
color |
|
depth |
The depth of the mobject. |
fill_color |
If there are multiple colors (for gradient) this returns the first one |
height |
The height of the mobject. |
n_points_per_curve |
|
sheen_factor |
|
stroke_color |
|
width |
The width of the mobject. |
_add_brackets(left='[', right=']', **kwargs)
Adds the brackets to the Matrix mobject.
See Latex document for various bracket types.
- Parameters:
- left (str) β the left bracket, by default β[β
- right (str) β the right bracket, by default β]β
- kwargs (Any)
- Returns: The current matrix object (self).
- Return type:
Matrix
_original__init__(matrix, v_buff=0.8, h_buff=1.3, bracket_h_buff=0.25, bracket_v_buff=0.25, add_background_rectangles_to_entries=False, include_background_rectangle=False, element_to_mobject=<class 'manim.mobject.text.tex_mobject.MathTex'>, element_to_mobject_config={}, element_alignment_corner=array([ 1., -1., 0.]), left_bracket='[', right_bracket=']', stretch_brackets=True, bracket_config={}, **kwargs)
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
- matrix (Iterable)
- v_buff (float)
- h_buff (float)
- bracket_h_buff (float)
- bracket_v_buff (float)
- add_background_rectangles_to_entries (bool)
- include_background_rectangle (bool)
- element_to_mobject (type *[*Mobject ] | Callable [ [ ... ] , Mobject ])
- element_to_mobject_config (dict)
- element_alignment_corner (Sequence *[*float ])
- left_bracket (str)
- right_bracket (str)
- stretch_brackets (bool)
- bracket_config (dict)
- kwargs (Any)
add_background_to_entries()
Add a black background rectangle to the matrix, see above for an example.
- Returns: The current matrix object (self).
- Return type:
Matrix
get_brackets()
Return the bracket mobjects.
- Returns: A VGroup containing the left and right bracket.
- Return type:
VGroup
Examples
get_columns()
Return columns of the matrix as VGroups.
- Returns: The VGroup contains a nested VGroup for each column of the matrix.
- Return type:
VGroup
Examples
get_entries()
Return the individual entries of the matrix.
- Returns: VGroup containing entries of the matrix.
- Return type:
VGroup
Examples
get_mob_matrix()
Return the underlying mob matrix mobjects.
- Returns: Each VGroup contains a row of the matrix.
- Return type:
List[
VGroup]
get_rows()
Return rows of the matrix as VGroups.
- Returns: The VGroup contains a nested VGroup for each row of the matrix.
- Return type:
VGroup
Examples
set_column_colors(*colors)
Set individual colors for each columns of the matrix.
- Parameters: colors (str) β The list of colors; each color specified corresponds to a column.
- Returns: The current matrix object (self).
- Return type:
Matrix
Examples
set_row_colors(*colors)
Set individual colors for each row of the matrix.
- Parameters: colors (str) β The list of colors; each color specified corresponds to a row.
- Returns: The current matrix object (self).
- Return type:
Matrix