sdynpy.core.sdynpy_geometry.ShapePlotter
- class ShapePlotter(geometry, shapes, plot_kwargs, background_plotter_kwargs={'auto_update': 0.01}, undeformed_opacity=0.25, starting_scale=1.0, deformed_opacity=1.0, shape_name='Mode', show_damping=True)[source]
Bases:
GeometryPlotter
Class used to plot animated shapes
- __init__(geometry, shapes, plot_kwargs, background_plotter_kwargs={'auto_update': 0.01}, undeformed_opacity=0.25, starting_scale=1.0, deformed_opacity=1.0, shape_name='Mode', show_damping=True)[source]
Create a Shape Plotter object to plot shapes
- Parameters
geometry (Geometry) – Geometry on which the shapes will be plotted
shapes (ShapeArray) – Shapes to plot on the geometry
plot_kwargs (dict) – Keyword arguments passed to the Geometry.plot function
background_plotter_kwargs (dict, optional) – Keyword arguments passed to the BackgroundPlotter constructor. The default is {‘auto_update’:0.01}.
undeformed_opacity (float, optional) – Opacity of the undeformed geometry. Set to zero for no undeformed geometry. The default is 0.25.
starting_scale (float, optional) – Starting scale of the shapes on the plot. The default is 1.0.
shape_name (str, optional) – Name that will be used in the plotter to describe the shape. The default is “Mode”
show_damping (bool, optional) – Boolean that specifies whether the damping should be displayed in the comment.
Methods
__init__
(geometry, shapes, plot_kwargs[, ...])Create a Shape Plotter object to plot shapes
Adds the menu bar to the BackgroundPlotter
Adds toolbars to the BackgroundPlotter
compute_displacements
([compute_scale])Computes displacements to apply to the geometry
Increases the index of the shape being plotted
Starts the animation playing
Decreases the index of the shape being plotted
Resets a shape if the value of the current shape is changed
save_animation
([filename, frames, ...])Saves the current shape animation to a file
save_animation_all_shapes
([filename_base, ...])Helper function to easily save animations for all shapes
Adjusts how complex shapes are plotted
Adjusts the current shape scaling by 0.25x
Adjusts the current shape scaling by 0.5x
Adjusts the current shape scaling by 0.8x
Resets shape scaling to 1
Adjusts the current shape scaling by 1.25x
Adjusts the current shape scaling by 2x
Adjusts the current shape scaling by 4x
Adjusts the current animation speed by 0.8
Resets animation speed to default quantities
Adjusts the current animation speed by 1.25
Shows or hides the shape comment
Stops the animation from playing
Updates the shape that is being plotted
update_shape_mode
([phase])Updates the mode that is being plotted
Attributes
Adds the menu bar to the BackgroundPlotter
- compute_displacements(compute_scale=True) ndarray [source]
Computes displacements to apply to the geometry
- Parameters
compute_scale (bool, optional) – Renormalize the displacement scaling. The default is True.
- save_animation(filename=None, frames=20, frame_rate=20, individual_images=False)[source]
Saves the current shape animation to a file
- Parameters
filename (str, optional) – Path to the file being saved. The default is None, which returns the images as an array rather than saves them to a file
frames (int, optional) – Number of frames in the animation. The default is 20.
frame_rate (float, optional) – Number of frames per second if the animation is saved to a GIF. The default is 20.
individual_images (bool, optional) – Boolean to specify whether the images are saved as individual PNG files or a single GIF. The default is False.
- Returns
imgs – Returns array of images if filename is None, otherwise returns None
- Return type
np.ndarray or None
- save_animation_all_shapes(filename_base='Shape_{:}.gif', frames=20, frame_rate=20, individual_images=False)[source]
Helper function to easily save animations for all shapes
- Parameters
filename_base (str, optional) – Filename that will be passed to the format function to produce the actual file name for each shape. The default is ‘Shape_{:}.gif’.
frames (int, optional) – Number of frames in the animation. The default is 20.
frame_rate (float, optional) – Number of frames per second if the animation is saved to a GIF. The default is 20.
individual_images (bool, optional) – Boolean to specify whether the images are saved as individual PNG files or a single GIF. The default is False.