Visualization

Here are some frequently used plot types with the packages pyqtgraph and/or matplotlib implemented. The respective pyinduct.visualization plotting function get an EvalData object whose definition also placed in this module. A EvalData-object in turn can easily generated from simulation data. The function pyinduct.simulation.simulate_system() for example already provide the simulation result as EvalData object.

show(show_pg=True, show_mpl=True, force=False)[source]

Shortcut to show all pyqtgraph and matplotlib plots / animations.

Parameters:
  • show_pg (bool) – Show matplotlib plots? Default: True
  • show_mpl (bool) – Show pyqtgraph plots? Default: True
  • force (bool) – Show plots even during unittest discover, setup and so on? Default: False
create_colormap(cnt)[source]

Create a colormap containing cnt values.

Parameters:cnt (int) –
Returns:Colormap …
class PgAnimatedPlot(data, title='', refresh_time=40, replay_gain=1, save_pics=False, create_video=False, labels=None)[source]

Bases: pyinduct.visualization.PgDataPlot

Wrapper that shows an updating one dimensional plot of n-curves discretized in t time steps and z spatial steps. It is assumed that time propagates along axis0 and and location along axis1 of values. Values are therefore expected to be a array of shape (n, t, z).

Parameters:
  • data ((iterable of) EvalData) – results to animate
  • title (basestring) – window title
  • refresh_time (int) – time in msec to refresh the window must be greater than zero
  • replay_gain (float) – values above 1 acc- and below 1 decelerate the playback process, must be greater than zero
  • save_pics (bool) –
  • labels

    ??

Return:

exported_files
class PgSurfacePlot(data, scales=None, animation_axis=None, title='')[source]

Bases: pyinduct.visualization.PgDataPlot

Plot 3 dimensional data as a surface using OpenGl.

Parameters:
  • data (EvalData) – Data to display, if the the input-vector has length of 2, a 3d surface is plotted, if has length 3, this surface is animated. Hereby, the time axis is assumed to be the first entry of the input vector.
  • scales (tuple) – Factors to scale the displayed data, each entry corresponds to an axis in the input vector with one additional scale for the output_data. It therefore must be of the size: len(input_data) + 1 . If no scale is given, all axis are scaled uniformly.
  • animation_axis (int) – Index of the axis to use for animation. Not implemented, yet and therefore defaults to 0 by now.
  • title (str) – Window title to display.

Note

For animation this object spawns a QTimer which needs an running event loop. Therefore remember to store a reference to this object.

class MplSurfacePlot(data, keep_aspect=False, fig_size=(12, 8), zlabel='$\quad x(z, t)$')[source]

Bases: pyinduct.visualization.DataPlot

Plot as 3d surface.

class MplSlicePlot(eval_data_list, time_point=None, spatial_point=None, ylabel='', legend_label=None, legend_location=1, figure_size=(10, 6))[source]

Bases: pyinduct.visualization.PgDataPlot

Get list (eval_data_list) of ut.EvalData objects and plot the temporal/spatial slice, by spatial_point/time_point, from each ut.EvalData object, in one plot. For now: only ut.EvalData objects with len(input_data) == 2 supported

visualize_roots(roots, grid, func, cmplx=False, return_window=False)[source]

Visualize a given set of roots by examining the output of the generating function.

Parameters:
  • roots (array like) – Roots to display, if None is given, no roots will be displayed, this is useful to get a view of func and choosing an appropriate grid.
  • grid (list) – List of arrays that form the grid, used for the evaluation of the given func.
  • func (callable) – Possibly vectorial function handle that will take input of of the shape (‘len(grid)’, ).
  • cmplx (bool) – If True, the complex valued func is handled as a vectorial function returning [Re(func), Im(func)].
  • return_window (bool) – If True the graphics window is not shown directly. In this case, a reference to the plot window is returned.

Returns: A PgPlotWindow if delay_exec is True.

visualize_functions(functions, points=100, return_window=False)[source]

Visualizes a set of Function s on their domain.

Parameters:
  • functions (iterable) – collection of Function s to display.
  • points (int) – Points to use for sampling the domain.
  • return_window (bool) – If True the graphics window is not shown directly. In this case, a reference to the plot window is returned.

Returns: A PgPlotWindow if delay_exec is True.