Reference 〉Class

MPLVisualization( Helipad model )

An abstract class with some basic functionality for Matplotlib visualizations, such as keypress handling and axes instantiation. This class is subclassed by user visualizations, and itself a subclass of BaseVisualization. It should not be instantiated directly and cannot be used directly as a visualization class.

Initialization Parameters

  • model Helipad, required

    The model object.


Click a method name for more detailed documentation.

  • addKeypress( key, fn )

    Registers a function to be run when a key is pressed in a Matplotlib visualizer. fn will run if key is pressed at any time when the plot window is in focus. To narrow the focus to a particular plot, define catchKeypress() in a subclass of ChartPlot.

  • event( t, color, **kwargs )

    Called when an event is triggered, in order to be reflected in the visualization. For example, a line is drawn in TimeSeries, and the background flashes in Charts. Any kwargs passed to model.addEvent() are passed to this function, allowing subclasses to receive custom arguments (for example, linestyle in TimeSeries.event()). This method is mandatory for subclasses to implement.

    This function is called automatically when an event is triggered and should not be called by user code.

  • launch( title )

    Launches the visualization window (if in Tkinter) or cell (if in Jupyter). This method is required to be implemented by subclasses, which should call super().launch(title) after creating the Matplotlib figure object.

  • sendEvent( event )

    An event handler for Matplotlib-based visualizations that executes functions registered with MPLVisualization.addKeypress() and routes other events to the appropriate ChartPlot object depending on the current mouse position, which are received by ChartPlot.MPLEvent(). This function should not be called directly by user code.

    sendEvent() currently routes key_press_event (keystrokes), button_press_event (mouse clicks), and pick_event (mouse clicks associated with particular pickable Artists).

  • terminate( )

    Cleanup on model termination. This function is called automatically from model.terminate() and should not be called from user code.

  • update( data )

    Updates the visualization with new data and refreshes the display. This is mandatory for any subclasses to implement. Subclasses implementing this method should also use it to store any data necessary for future visualizer operations.

    This function should only rarely be called by the user; call model.step() instead to increment the model by one period and update the graph.


  • isNull bool

    True when the model should run as-if with no visualization, for example if all the plots are unselected. False indicates the window can be launched.

  • lastUpdate int

    Because the model can be set to refresh the visualization only every so many periods, this property records the model time when data was last drawn to the visualization.

    Initial value: 0

  • fig matplotlib.Figure

    The Matplotlib Figure object used for rendering the visualization as a whole.

  • plots dict{str:Plot}

    A dict of registered TimeSeriesPlot objects.

  • activePlots dict{str:Plot}

    A dynamic property consisting of the subset of the plots containing the Plots that are currently active.

  • keys dict{str: list[func]}

    Where functions defined in MPLVisualization.addKeypress() are stored.

    Initial value: {}


Click a hook name for more detailed documentation.

  • visualRefresh( model, visual )

    Runs when the visualizer updates, every n periods as determined by the refresh parameter.

  • visualLaunch( model, visual )

    Runs when model.launchVisual() is called, after the visualization is launched. Use the modelPostSetup hook to catch before the visualization is launched.

Notes and Examples

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.