plotter module

Define the generic Plotter.

class Plotter(*args, **kwargs)[source]

Bases: object

An object used to plot data.

__init__(*args, **kwargs)[source]
abstract plot(data, x, y, grid=True, axes=None, xlabel=None, ylabel=None, label=None, **kwargs)[source]

Plot 2D data.

Parameters:
  • data (pandas.DataFrame) – Holds all data to plot.

  • x (str) – Name of column in data for x/y.

  • y (str) – Name of column in data for x/y.

  • grid (bool, optional) – If grid should be plotted. Default is True.

  • axes (Any | None, optional) – Axes to re-use, if provided. The default is None (plot on new axis).

  • xlabel (str | None, optional) – Name of the labels. If not provided, we use the markdown equivalent of x/y, if defined in markdown.

  • ylabel (str | None, optional) – Name of the labels. If not provided, we use the markdown equivalent of x/y, if defined in markdown.

  • label (str | None, optional) – If provided, overrides the legend. Useful when several simulations are shown on the same plot.

  • kwargs – Other keyword passed to the actual plot method.

Return type:

tuple[Any, Any]

Returns:

  • Any – Axis object.

  • Any – Color used for the plot.

abstract hist(data, x, bins=200, hist_range=None, **kwargs)[source]

Plot a histogram.

Parameters:
  • data (pandas.DataFrame) – Holds all data to plot.

  • x (PARTICLE_0D_t) – Name of the column in data to plot.

  • bins (int, optional) – Number of bins in the histogram. The default is 200.

  • hist_range (tuple[float, float] | None, optional) – Lower and upper range for the calculation of the histogram. The default is None.

  • kwargs – Other keyword arguments passed to the actual plot method.

Returns:

Axis object.

Return type:

Any

abstract plot_3d(data, key, *args, **kwargs)[source]

Create a 3D plot.

Parameters:
  • data (Any) – Object storing the data to plot.

  • key (PARTICLE_3D_t) – Name/nature of the data to plot.

Return type:

Any

abstract load_mesh(stl_path, stl_alpha=None, **kwargs)[source]

Load the 3D mesh.

Parameters:
  • stl_path (str | Path) – Path to the STL file.

  • stl_alpha (float | None, optional) – Transparency for the mesh. The default is None.

Returns:

Mesh object.

Return type:

Any

abstract plot_mesh(mesh, *args, **kwargs)[source]

Plot a 3D mesh.

Parameters:

mesh (Any)

Return type:

Any

abstract plot_trajectory(points, emission_color=None, collision_color=None, collision_point=array([], dtype=float64), lw=7, r=8, **kwargs)[source]

Plot the Particle trajectory stored in points.

Parameters:
  • points (list[ndarray[tuple[Any, ...], dtype[float64]]]) – List of positions, as returned by Vector.to_list().

  • emission_color (str | None, default: None) – If provided, the first known position is colored with this color.

  • collision_color (str | None, default: None) – If provided, the last known position is colored with this color.

  • collision_point (ndarray[tuple[Any, ...], dtype[float64]], default: array([], dtype=float64)) – If provided and collision_color is not None, we plot this point instead of the last of points. This is useful when the extrapolated time is large, and actuel collision point may differ significantly from last position points.

  • lw (int, default: 7) – Trajectory line width.

  • r (int, default: 8) – Size of the emission/collision points.

Return type:

Any

show()[source]

Show the plots that were produced.

Useful for the bash interface.

Return type:

None