I plot data on top of a plot with a fresh pen.

Begin micro-behaviour


Begin NetLogo code:
substitute-text-area-for columns: 58 plot-label Hunger Plot
substitute-text-area-for columns: 57 color-of-pen red
substitute-text-area-for name-of-pen Hunger      
substitute-text-area-for columns: 69 rows: 3 x-value time
substitute-text-area-for columns: 69 rows: 3 y-value my-hunger
substitute-text-area-for columns: 71 cycle-duration 1
substitute-text-area-for columns: 80 rows: 5 comment ; Notes                                                                                     
substitute-text-area-for columns: 58 kind-of-pen 0 
substitute-text-area-for columns: 76 erase-pen ; plot-pen-reset
do-every cycle-duration
   [set-current-plot "plot-label"
    create-temporary-plot-pen "name-of-pen" ; this name will be used in the legend if enabled
    set-plot-pen-color color-of-pen
    set-plot-pen-mode kind-of-pen ; 0 for line, 1 for bar, 2 for point
    erase-pen ; remove the ';' in the box to erase everything drawn by this pen
    plotXY x-value
End NetLogo code


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.

Related Micro-behaviours

USE-PEN-TO-ADD-TO-PLOT -- I use a previously declared pen add to a plot

CREATE-PLOT -- I create a fully specified two-dimensional graph

CREATE-AUTO-PLOT -- I create a plot that scales dynamically as the data is produced

CREATE-EMPTY-PLOT -- I create a fully specified area where other micro-behaviours can draw graphs

CREATE-EMPTY-AUTO-PLOT -- I create an area that scales dynamically as where other micro-behaviours draw graphs

CREATE-HISTOGRAM -- I create a histogram 

How this works

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


ADD-TO-PLOT was implemented by Ken Kahn on 16 November 2009.