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

Create plot

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Set up and maintain a plot of two variables, e.g. hunger versus time. The location, size, minimum, and maximum values are all specified.

End description

Create plot

Begin NetLogo code:

substitute-text-area-for upper-left-corner-x 5    
substitute-text-area-for upper-left-corner-y 550 
substitute-text-area-for lower-right-corner-x 420  
substitute-text-area-for lower-right-corner-y 809 
substitute-text-area-for plot-label Random Plot     
substitute-text-area-for x-axis-label time        
substitute-text-area-for y-axis-label random      
substitute-text-area-for x-axis-value time               
substitute-text-area-for y-axis-value random 200          
substitute-text-area-for minimum-x-value 0   
substitute-text-area-for maximum-x-value 100 
substitute-text-area-for minimum-y-value 0   
substitute-text-area-for maximum-y-value 200 
substitute-text-area-for legends "random value" "black"                                   
create-plot
  "upper-left-corner-x" "upper-left-corner-y" ; upper left corner 
  "lower-right-corner-x" "lower-right-corner-y" ; lower right corner
  "plot-label" ; unique name (and label) for this plot
  "x-axis-label" ; X axis label
  "y-axis-label" ; Y axis label
  (x-axis-value) ; X axis value
  (y-axis-value) ; Y axis value
  "minimum-x-value" ; minimum x value
  "maximum-x-value" ; maximum x value
  "minimum-y-value" ; minimum y value
  "maximum-y-value" ; maximum y value
  legends
  ; legends is either alternating pen names and color names, false meaning no legend, or 
  ; true meaning legend generated via Add to plot

End NetLogo code

Variants

You can change all the attributes in text areas to change the size, location, labels, minimum, or maximum values. You can plot other attributes. For example, replace y-axis-value text area with count all-of-kind "fish" to graph the fish population.The x-axis-value text area need not be time. You can add a legend by editing the last text area. Supported colors are black, white, gray, red, orange, brown, yellow, green, lime, turquoise, cyan, sky, blue, violet, magenta, and pink. To remove all legends edit the last area to be empty.

How this works

This uses the Behaviour Composer primitive create-plot that defines a plot in the NetLogo file that is added during loading and cannot be removed during a run.

Related micro-behaviours

Create auto plot differs from this in that the scales are computed automatically and dynamically.  Create empty plot  creates a plotting area that can have many plots drawn on it using Add to plot.

History

Create plot was implemented by Ken Kahn.

BehaviourComposer: ignore everything after this.

Comments