LivePlotter Class¶
- class automationshield.plotting.LivePlotter(shield: BaseShield, show_dt: bool = True, show_ref: bool = True, show_pot: bool = False, hold: bool = False)[source]¶
Bases:
PlotterThis class can be used to plot during an experiment. Create an instance of
LivePlotterand pass it to your controller’srun()method with thelive_plotterkeyword argument:Example:
>>> shield = AeroShield() >>> plotter = LivePlotter(shield=shield, hold=True) >>> results = MyController(shield).run(freq=200, cycles=1000, live_plotter=plotter)
This will show a plot that will update during the experiment.
LivePlotterinherits fromPlotterand looks mostly identical. However, in order to keep the update loop as fast as possible, The plot limits are set beforehand, based on the run time and bounds of the shield that is being used.LivePlottertakes the same arguments asPlotterin addition to some extra parameters.The shield parameter is not optional for a
LivePlotterinstance. A shield instance is required to set the plot limits.- Parameters:
hold (bool, optional) – Whether to keep showing the plot when the experiment is finished, defaults to False. If
True, a call tomatplotlib.pyplot.show()will block until the window is closed manually. If used in a Jupyter environment, hold must be set toFalse. Otherwise, the plot window will stop responding, causing the Jupyter kernel to crash.shield (BaseShield)
show_dt (bool)
show_ref (bool)
show_pot (bool)
- default_refresh_interval = 0.016666666666666666¶
Default refresh interval of the plot window in seconds.
- setup_figure(shield: BaseShield) tuple[Figure, ndarray[Any, dtype[Axes]]][source]¶
Create empty figure with axes. Add labels, titles, grids, …
- Parameters:
shield (BaseShield) – Shield instance.
- Returns:
Figure and (array of) axes.
- Return type:
tuple[plt.Figure, np.ndarray[Any, np.dtype[plt.Axes]]]
- setup_artists(shield: BaseShield) tuple[dict[str, Line2D], list[Artist]][source]¶
Add lines to plot data for later. Add legends and text. Anything that should be updated/moved or redrawn each loop should be defined here. Anything that should be updated should be added to a dictionary with a key of your choice. Artists that should only be moved/redrawn should be added to a list.
- Parameters:
shield (BaseShield) – Shield instance.
- Returns:
dictionary of artists that should be updated and list of artists that only need to be redrawn.
- Return type: