Libraries‎ > ‎Library‎ > ‎Graphing‎ > ‎

Add to plot and generate pen name

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Graph data on top of a plot with a fresh pen. Typically you'll want to enhance this to happen repeatedly.

End description

Add to plot

Begin NetLogo code:

substitute-text-area-for plot-label Hunger Plotsubstitute-text-area-for color-of-pen redsubstitute-text-area-for name-of-pen (word "Hunger" who)      substitute-text-area-for x-value timesubstitute-text-area-for y-value my-hungersubstitute-text-area-for kind-of-pen 0 substitute-text-area-for erase-pen ; plot-pen-resetset-current-plot "plot-label"create-temporary-plot-pen name-of-pen ; this name will be used in the legend if enabledset-plot-pen-color color-of-penset-plot-pen-mode kind-of-pen ; 0 for line, 1 for bar, 2 for pointerase-pen ; remove the ';' in the box to erase everything drawn by this penadd-to-plot x-value            y-value

End NetLogo code

Variants

You can change any of the values in text boxes. Named colours are black, white, gray, red, orange, brown, yellow, green, lime, turquoise, cyan, sky, blue, violet, magenta, and pink.More colors can be specified. If you are using this behaviour for many agents then you probably want to choose a color depending upon the identity of the agent. You can use NetLogo's who reporter for this.

How this works

It creates a temporary pen and uses it to update the plot named in the first text box.

Related micro-behaviours

Add pen to add to plot adds to a plot with a pre-defined pen. Create empty plot or Create empty auto plot can create a surface for this to draw upon.

History

Add to plot was implemented by Ken Kahn.

BehaviourComposer: ignore everything after this.