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

Create histogram

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Set up and maintain a histogram.

End description

Create histogram

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 histogram-label Size Distribution
substitute-text-area-for x-axis-label Size
substitute-text-area-for y-axis-label Number of individuals
substitute-text-area-for x-axis-value all-individuals
substitute-text-area-for y-axis-value size
substitute-text-area-for minimum-x-value 0  
substitute-text-area-for maximum-x-value 5  
substitute-text-area-for minimum-y-value 0  
substitute-text-area-for maximum-y-value 10
substitute-text-area-for legends "label" "red"                                                                                            
create-histogram
  "upper-left-corner-x" "upper-left-corner-y" ; upper left corner 
  "lower-right-corner-x" "lower-right-corner-y" ; lower right corner
  "histogram-label" ; unique name (and label) for this plot
  "x-axis-label" ; X axis label
  "y-axis-label" ; Y axis label
  (x-axis-value) ; the population
  (y-axis-value) ; value being displayed
  "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 (alternating pen names and color names or false for no legends)

End NetLogo code

Variants

One can make histograms of any numeric values. This example maintains a histogram named "Size Distribution". You can restrict the population by replacing the x-axis-value text area with another expression such as all-of-kind "fish"

How this works

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

Related micro-behaviours

History

Create histogram was implemented by Ken Kahn.

BehaviourComposer: ignore everything after this.

Comments