ChartPlot is an extensible class that registers a plot area in the
Charts visualizer. Each of the three panels in the screenshot of the
Charts visualizer to the right corresponds to an instantiated subclass of
ChartPlot. Overridden methods may take a variety of kwargs from
Charts.addPlot() to support custom uses. It may plot current model data (as the
BarChart does), or visualize other aspects of the model state (as
This class should be subclassed, and cannot be drawn by itself. At minimum, subclasses must implement the
draw() methods, specify the
type property, and maintain the
axes property after launch in order to be drawn properly in the
Click a method name for more detailed documentation.
draw( t, forceUpdate )
axesobject for display on the visualizer. This function is called after
ChartPlot.update()when the visualizer receives new data, and when scrubbing the time bar. The
update()method, therefore, should be used to store model data by time, which can then be used by
Charts will refresh the entire canvas after updating each of the individual plots, so there is no need to refresh the canvas manually here unless it is desired to redraw the graph out of sync (e.g. if the subclass provides for interactivity and the plot should update while the model is paused).
Subclasses should call
super().draw(t, forceUpdate)at the end of the function.
update( data, t )
Receives current model data and stores it for future scrubbing.
Note that this function is called when the visualizer receives new data from the model. Because
ChartPlot.draw()is called both after
ChartPlot.update()and when the time bar is scrubbed, drawing code should be but in
ChartPlot.draw()and not here, unless there is code to be run only in the event of new data that should not be run when scrubbing (e.g. calculating new plot bounds).
If the visualizer needs model properties besides the current data, the model object can be accessed with
This function should not typically be called from user code, though it can be for out-of-sync plot updates when interacting with a plot. See the
networkNodeClickhook for an example.
launch( axes )
Initial code to set up
Chartslaunches the visualization window. Subclasses should call
super().launch()at the beginning of the method. This function should not be called from user code.
type — str
A short identifying string, to be used in the
name — str
A short name, used to refer back to the plot afterward.
label — str
The title of the chart, displayed above it in the visualizer.
axes — matplotlib.AxesSubplot
projection — str
The Matplotlib coordinate projection to use.
'rectilinear', but other projections available by default are
'mollweide'. Custom Matplotlib projection objects can also be passed to this argument.
Initial value: None
viz — Charts
selected — bool
Whether or not the plot should be drawn when