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

add_menu_bar()

Adds the menu bar to the BackgroundPlotter

add_toolbars()

Adds toolbars to the BackgroundPlotter

compute_displacements([compute_scale])

Computes displacements to apply to the geometry

next_shape()

Increases the index of the shape being plotted

play_animation()

Starts the animation playing

prev_shape()

Decreases the index of the shape being plotted

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

save_animation_from_action()

select_complex()

Adjusts how complex shapes are plotted

select_loop()

select_scaling_0p25()

Adjusts the current shape scaling by 0.25x

select_scaling_0p5()

Adjusts the current shape scaling by 0.5x

select_scaling_0p8()

Adjusts the current shape scaling by 0.8x

select_scaling_1()

Resets shape scaling to 1

select_scaling_1p25()

Adjusts the current shape scaling by 1.25x

select_scaling_2p0()

Adjusts the current shape scaling by 2x

select_scaling_4p0()

Adjusts the current shape scaling by 4x

select_shape()

select_speed_0p8()

Adjusts the current animation speed by 0.8

select_speed_1()

Resets animation speed to default quantities

select_speed_1p25()

Adjusts the current animation speed by 1.25

show_comment()

Shows or hides the shape comment

stop_animation()

Stops the animation from playing

toggle_undeformed()

update_shape()

Updates the shape that is being plotted

update_shape_mode([phase])

Updates the mode that is being plotted

Attributes

add_menu_bar() None[source]

Adds the menu bar to the BackgroundPlotter

add_toolbars() None[source]

Adds toolbars 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.

next_shape() None[source]

Increases the index of the shape being plotted

play_animation()[source]

Starts the animation playing

prev_shape() None[source]

Decreases the index of the shape being plotted

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.

save_animation_from_action()[source]
select_complex() None[source]

Adjusts how complex shapes are plotted

select_loop() None[source]
select_scaling_0p25()[source]

Adjusts the current shape scaling by 0.25x

select_scaling_0p5()[source]

Adjusts the current shape scaling by 0.5x

select_scaling_0p8()[source]

Adjusts the current shape scaling by 0.8x

select_scaling_1()[source]

Resets shape scaling to 1

select_scaling_1p25()[source]

Adjusts the current shape scaling by 1.25x

select_scaling_2p0()[source]

Adjusts the current shape scaling by 2x

select_scaling_4p0()[source]

Adjusts the current shape scaling by 4x

select_shape() None[source]
select_speed_0p8()[source]

Adjusts the current animation speed by 0.8

select_speed_1()[source]

Resets animation speed to default quantities

select_speed_1p25()[source]

Adjusts the current animation speed by 1.25

show_comment()[source]

Shows or hides the shape comment

stop_animation()[source]

Stops the animation from playing

toggle_undeformed() None[source]
update_shape()[source]

Updates the shape that is being plotted

update_shape_mode(phase=None)[source]

Updates the mode that is being plotted

Parameters

phase (float, optional) – Sets the current phase of the shape. The default is None, which computes the new phase based on the time elapsed.