symbrim.utilities.plotting.Plotter¶
- class symbrim.utilities.plotting.Plotter(inertial_frame, zero_point, ax=None, **inertial_frame_properties)¶
Bases:
Scene3D
Plotter for models created by SymBRiM using SymMePlot.
Attributes
Coordinate where the annotation text is displayed.
String describing where the annotation should be displayed.
Artists used to plot the object.
Axes used by the scene.
Plot objects.
The reference frame with respect to which all objects will be oriented.
Plot objects.
List of evaluated values for the object's variables.
The absolute origin with respect to which all objects will be positioned.
Methods
Add a sympy body to the scene.
Add a connection to the plotter.
Add a sympy ReferenceFrame to the scene.
Add a sympy Vector to the scene.
Add a load group to the plotter.
Add a model to the plotter.
Add a plot object to the scene.
Add a sympy Vector to the scene.
Add a sympy Vector to the scene.
Animate the scene.
Auto scale the axis.
Clear the axes.
Evaluate the system using the function created with
lambdify_system
.Initialize the plotter.
Return a tuple of the necessary expressions for plotting.
Return the plot_object based on a sympy object.
Lambdify the system.
Plot all plot objects.
Hide or show a
plot_object
based on asympy_object
.Update the objects on the scene, based on the currect values.
- __init__(inertial_frame, zero_point, ax=None, **inertial_frame_properties)¶
- __weakref__¶
list of weak references to the object (if defined)
- add_body(body, **kwargs)¶
Add a sympy body to the scene.
- Parameters:
body (RigidBody or Particle) – The body that should be plotted.
**kwargs (dict, optional) – Kwargs that are parsed to both internally used plot objects.
- Returns:
The added plot object.
- Return type:
PlotBody
- add_connection(connection: ConnectionBase, **kwargs: dict[str, object]) PlotConnection ¶
Add a connection to the plotter.
- Parameters:
connection (ConnectionBase) – Connection to add.
**kwargs – Keyword arguments are passed to
symbrim.utilities.plotting.PlotConnection
.
- add_frame(frame: ReferenceFrame, origin: Point | Vector | None = None, **kwargs)¶
Add a sympy ReferenceFrame to the scene.
- Parameters:
frame (ReferenceFrame) – The reference frame that should be plotted.
origin (Point, Vector, optional) – The origin of the reference frame. Default is the zero_point.
**kwargs (dict, optional) – Kwargs that are parsed to plot object.
- Returns:
The added plot object.
- Return type:
PlotFrame
- add_line(points: Iterable[Point | Vector], name: str | None = None, **kwargs)¶
Add a sympy Vector to the scene.
- add_load_group(load_group: LoadGroupBase, **kwargs: dict[str, object]) PlotLoadGroup ¶
Add a load group to the plotter.
- Parameters:
load_group (LoadGroupBase) – Load group to add.
**kwargs – Keyword arguments are passed to
symbrim.utilities.plotting.PlotLoadGroup
.
- add_model(model: ModelBase, **kwargs: dict[str, object]) PlotModel ¶
Add a model to the plotter.
- Parameters:
model (ModelBase) – Model to add.
**kwargs – Keyword arguments are passed to
symbrim.utilities.plotting.PlotModel
.
- add_plot_object(plot_object: PlotBase)¶
Add a plot object to the scene.
- Parameters:
plot_object (PlotBase) – The plot object that should be added.
- add_point(point: Point | Vector, **kwargs) type[PlotBase] ¶
Add a sympy Vector to the scene.
- Parameters:
point (Point or Vector) – The point or vector to be plotted as point in space.
**kwargs – Keyword arguments are parsed to the plot object.
- Returns:
The added plot object.
- Return type:
PlotPoint
- add_vector(vector: Vector, origin: Point | Vector | None = None, **kwargs)¶
Add a sympy Vector to the scene.
- Parameters:
vector (Vector) – The vector that should be plotted with respect to the zero_point.
origin (Point, Vector, optional) – The origin of the reference frame. Default is the zero_point.
**kwargs (dict, optional) – Kwargs that are parsed to the plot object.
- Returns:
The added plot object.
- Return type:
PlotVector
- animate(get_args: Callable[[Any], tuple], frames: Iterable[Any] | int, interval: int = 30, **kwargs) FuncAnimation ¶
Animate the scene.
- Parameters:
get_args (Callable) – Function that returns the arguments for the
evaluate_system
method. The function should takes the current frame as input.frames (int or iterable) – Number of frames or iterable with frames.
interval (int, optional) – Time interval between frames in milliseconds. Default is 30.
**kwargs – Keyword arguments are parsed to the
matplotlib.animation.FuncAnimation
.
- Returns:
Animation object.
- Return type:
matplotlib.animation.FuncAnimation
- property annot_coords¶
Coordinate where the annotation text is displayed.
- property annot_location¶
String describing where the annotation should be displayed.
Explanation
String that is used to determine where the annotation should be displayed. Options are: - ‘object’: The annotation location is determined based on the plot_object
- property artists: tuple[ArtistBase, ...]¶
Artists used to plot the object.
- auto_zoom(scale=1.1)¶
Auto scale the axis.
- property axes¶
Axes used by the scene.
- clear()¶
Clear the axes.
Explanation
Remove all artists known by the instance. Only the inertial frame as plotobject in the scene.
- classmethod from_model(model: ModelBase, ax: Axes3D | None = None, **inertial_frame_properties: dict[str, object]) Self ¶
Initialize the plotter.
- Parameters:
model (ModelBase) – Model to plot.
ax (mpl_toolkits.mplot3d.axes3d.Axes3D, optional) – Axes to plot on. If None, a new figure is created.
**inertial_frame_properties – Keyword arguments are parsed to
symmeplot.plot_objects.PlotFrame
representing the inertial reference frame.
- get_plot_object(sympy_object: Any | str) PlotBase | None ¶
Return the plot_object based on a sympy object.
Explanation
Return the
plot_object
based on a provided sympy object. For exampleReferenceFrame('N')
will give thePlotFrame
of that reference frame. If theplot_object
has not been added it will returnNone
.- Parameters:
sympy_object (Any or str) – SymPy object to search for. If it is a string it will search for the name.
- Returns:
Retrieved plot object.
- Return type:
PlotBase or None
- property inertial_frame: ReferenceFrame¶
The reference frame with respect to which all objects will be oriented.
- lambdify_system(args, modules=None, printer=None, use_imps=True, dummify=False, cse=True) Callable ¶
Lambdify the system.
Explanation
Lambdify the system for faster evaluation, when combined with
symmeplot.core.scene.SceneBase.evaluate_system()
. Seesympy.utilities.lambdify.lambdify()
for more information.
- plot(prettify=True, ax_scale=1.5)¶
Plot all plot objects.
- Parameters:
- Returns:
Returns the plotted artists
- Return type:
tuple of artists