Reference 〉 Function

ChartPlot.draw(tint, forceUpdateboolFalse)

Updates the axes object 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 draw().

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.


  • t int, required

    The model time whose data to draw. Because the Charts visualizer disables the refresh parameter on runtime, Charts will never pass a value of t to draw() that has not already been passed to update(), where the data should be stored in the object.

  • forceUpdate bool, optional

    Charts refreshes all the plots at once each cycle. If interacting with a plot while the model is paused and it becomes necessary to update the display, forceUpdate can be used to refresh the display before the next cycle. Note that the plot's data must be updated with the update() method first.

    Default value: False

Notes and Examples

  1. charwick

    Feb 05, 2021 at 0:05

    An example of using update() and draw() to refresh the display while paused:

    #A user function that runs when the plot is interacted with and receives the plot object
    def agentClick(agent, plot, t):
    	if t != heli.t: return #Only run if the time bar is at the current model time
    	# Take some action here that requires an out-of-sync graph update
    	plot.update(, t) #Overwrite the visualizer's current-period data
    	plot.draw(t, forceUpdate=True) #Refresh the graph
  2. 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.