The AnimatedArtist
Class and Subclasses
- class src.matnimation.artist.animated.animated_artist.AnimatedArtist(name: str, vis_interval: list[int] | None = None)
Bases:
BaseArtist
,ABC
Animated Artist (line, circle, arrow etc) to be placed on a specific axis of a defined canvas.
- __init__(name: str, vis_interval: list[int] | None = None)
Initialize an Animated Artist.
- Parameters:
name (str) – Name of the animated artist
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF. If vis_interval = [1, 10], visibility will be turned ON at time index 1 and turned OFF at time index 10.
- set_styling_properties(**styling)
Set styling properties of the animated artist.
- Parameters:
**styling – Keyword arguments representing styling properties
- update_visibility(time_index: int)
Update the visibility of the animated artist based on the current time index.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_arrow.AnimatedArrow(name: str, x_tail_data: ndarray, y_tail_data: ndarray, x_tip_data: ndarray, y_tip_data: ndarray, vis_interval: list[int] | None = None, width: float = 0.001, head_width: float | None = None, head_length: float | None = None, overhang: float = 0)
Bases:
AnimatedArtist
- __init__(name: str, x_tail_data: ndarray, y_tail_data: ndarray, x_tip_data: ndarray, y_tip_data: ndarray, vis_interval: list[int] | None = None, width: float = 0.001, head_width: float | None = None, head_length: float | None = None, overhang: float = 0)
Initialize an Animated Circle.
- Parameters:
name (str) – Name of the animated circle
radius (float) – Radius of the circle
x_data (np.ndarray) – Array of x-values representing the center for all timesteps
y_data (np.ndarray) – Array of y-values representing the center for all timesteps
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF.
- update_timestep(time_index)
Update the center coordinates of the circle at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_circle.AnimatedCircle(name: str, radius: float, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, radius: float, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Initialize an Animated Circle.
- Parameters:
name (str) – Name of the animated circle
radius (float) – Radius of the circle
x_data (np.ndarray) – Array of x-values representing the center for all timesteps
y_data (np.ndarray) – Array of y-values representing the center for all timesteps
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF.
- update_timestep(time_index)
Update the center coordinates of the circle at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_ellipse.AnimatedEllipse(name: str, width: float, height: float, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None, width_data: ndarray | None = None, height_data: ndarray | None = None)
Bases:
AnimatedArtist
- __init__(name: str, width: float, height: float, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None, width_data: ndarray | None = None, height_data: ndarray | None = None)
Initialize an Animated Ellipse.
- Parameters:
name (str) – Name of the animated ellipse
width (float) – Width of the ellipse
height (float) – Height of the ellipse
x_data (np.ndarray) – Array of x-values representing the center for all timesteps
y_data (np.ndarray) – Array of y-values representing the center for all timesteps
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF.
width_data (np.ndarray, optional) – Array of ellipse-width at each timestep (default is None)
height_data (np.ndarray, optional) – Array of ellipse-height at each timestep (default is None)
- update_timestep(time_index)
Update the properties of the ellipse at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_imshow.AnimatedImshow(name: str, image_data: ndarray, extent: list, aspect: str = 'auto', cmap='viridis', vmin: float | None = None, vmax: float | None = None, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, image_data: ndarray, extent: list, aspect: str = 'auto', cmap='viridis', vmin: float | None = None, vmax: float | None = None, vis_interval: list[int] | None = None)
Initialize an AnimatedImshow object.
- Parameters:
name (str) – Name of the animated imshow
image_data (list of 2D numpy arrays) – Function values f(x,y) on grid for all timesteps. len(image_data) = len(time_array)
extent (list) – Extent over which image must be plotted in figure [xmin, xmax, ymin, ymax]
aspect (float or str) – Aspect ratio of imshow axes
cmap (str, optional) – Colormap style to be used (default is ‘viridis’)
vmin (float, optional) – Minimum value in data range covered by colormap (None by default) If None, value will be set the to minimum value in the image_data of the initial timestep
vmax (float, optional) – Maximum value in data range covered by colormap (None by default) If None, value will be set the to minimum value in the image_data of the initial timestep
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF
- add_to_axes(axes: Axes)
Add the artist to the specified axes.
- Parameters:
axes (Axes) – Matplotlib axes object
- set_styling_properties(**styling)
Set styling properties for the artist.
- Raises:
ValueError – If the artist has not been added to an axes yet
- Parameters:
**styling – Keyword arguments for styling properties
- update_timestep(time_index: int)
Update the imshow data at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_line.AnimatedLine(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Initialize an Animated Line.
- Parameters:
name (str) – Name of the animated line
x_data (np.ndarray) – x values of line (1D if they dont change over time, 2D if they do)
y_data (np.ndarray) – y values of line (rows) for all timesteps (cols)
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF
- update_timestep(time_index)
Update the line data at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_polygon.AnimatedPolygon(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Initialize an Animated Polygon.
- Parameters:
name (str) – Name of the animated polygon
x_data (np.ndarray) – x values of polygon (rows) for all timesteps (cols)
y_data (np.ndarray) – y values of polygon (rows) for all timesteps (cols)
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF
- update_timestep(time_index)
Update the polygon coordinates at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_quiver.AnimatedQuiver(name: str, x_data: ndarray, y_data: ndarray, Fx_data: ndarray, Fy_data: ndarray, scale: float = 1.0, scale_units: str | None = None, width: float | None = None, color='k', vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, x_data: ndarray, y_data: ndarray, Fx_data: ndarray, Fy_data: ndarray, scale: float = 1.0, scale_units: str | None = None, width: float | None = None, color='k', vis_interval: list[int] | None = None)
Initialize an Animated Quiver.
- Parameters:
name (str) – Name of the animated quiver
x_data (np.ndarray) – x coordinates of tails of vectors
y_data (np.ndarray) – y coordinates of tails of vectors
Fx_data (np.ndarray) – x-component of vectors (rows) at all timesteps (cols)
Fy_data (np.ndarray) – y-component of vectors (rows) at all timesteps (cols)
scale (float, optional) – Sets scale of vectors, by default 1.
scale_units (str, optional) – Units of the scale, by default None
width (float, optional) – Width of arrow shaft, by default None
color (str or RGBA seq, optional) – Arrow color, by default ‘k’
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF, by default None
- add_to_axes(axes: Axes)
Add the quiver to the given axes.
- Parameters:
axes (Axes) – Axes object to which the quiver will be added
- set_styling_properties(**styling)
Set styling properties for the quiver.
- Raises:
ValueError – If the artist has not been added to an axes yet
- Parameters:
**styling (dict) – Styling properties to be set
- update_timestep(time_index: int)
Update the quiver vector data at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_scatter.AnimatedScatter(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Initialize an Animated Scatter.
Scatter is interpreted here as a matplotlib Line2D object with no line (linewidth = 0) but with specified markers (marker = ‘.’) at all data points.
- Parameters:
name (str) – Name of the animated scatter
x_data (np.ndarray) – 1D array with x coodinations of scatter points (assuming x coordinates are time-INDEPENDENT) or 2D array wtih x coordinates (rows) of scatter points at all timesteps (cols)
y_data (np.ndarray) – 1D array with y coodinations of scatter points (assuming y coordinates are time-INDEPENDENT) or 2D array wtih y coordinates (rows) of scatter points at all timesteps (cols)
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF, by default None
- update_timestep(time_index: int)
Update the coordinates of scatters at specific timestep in animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_single_scatter.AnimatedSingleScatter(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Initialize an Animated Single Scatter.
Scatter is interpreted here as a matplotlib Line2D object with no line (linewidth = 0) but with specified markers (marker = ‘.’) at all data points.
- Parameters:
name (str) – Name of the animated scatter
x_data (np.ndarray) – Array with x coordinate of single scatter at all timesteps
y_data (np.ndarray) – Array with y coordinate of single scatter at all timesteps
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF, by default None
- set_styling_properties(**styling)
Set styling properties for the scatter.
Only supports styling properties related to the marker.
- Parameters:
**styling (dict) – Styling properties for the scatter
- update_timestep(time_index: int)
Set coordinates of scatter at specific timestep in animation.
- Parameters:
time_index (int) – Current time index
- class src.matnimation.artist.animated.animated_text.AnimatedText(name: str, text_str_data: list[str], text_x_data: ndarray, text_y_data: ndarray, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, text_str_data: list[str], text_x_data: ndarray, text_y_data: ndarray, vis_interval: list[int] | None = None)
Initialize an Animated Text.
Parameters:
- namestr
Name of the animated text.
- text_str_datalist[str]
List with text strings at all timesteps.
- text_x_datanp.ndarray
x position of text at all timesteps.
- text_y_datanp.ndarray
y position of text at all timesteps.
- vis_intervallist[int], optional
List with time indices at which visibility must be turned ON and OFF, by default None.
- class src.matnimation.artist.animated.animated_text.AnimatedTextBbox(name: str, animated_text: AnimatedText, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, animated_text: AnimatedText, vis_interval: list[int] | None = None)
Initialize an AnimatedTextBbox.
Parameters:
- namestr
Name of the animated text bounding box.
- animated_textAnimatedText
AnimatedText object to create a bounding box around.
- vis_intervallist[int], optional
List with time indices at which visibility must be turned ON and OFF, by default None.
- class src.matnimation.artist.animated.animated_trace.AnimatedTrace(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Bases:
AnimatedArtist
- __init__(name: str, x_data: ndarray, y_data: ndarray, vis_interval: list[int] | None = None)
Initialize an Animated Trace.
- Parameters:
name (str) – Name of the animated line
x_data (np.ndarray) – x values of complete trace over all timesteps
y_data (np.ndarray) – y values of complete trace over all timesteps
vis_interval (list[int], optional) – List with time indices at which visibility must be turned ON and OFF
- update_timestep(time_index)
Update the line data at a specific timestep in the animation.
- Parameters:
time_index (int) – Current time index