Netlogo: how to count the number of turtles with a specific color and plot them along the Y axis

I want to count the number of turtles with a specific color (red) and plot them on the Y-axis (the X-axis is ticks). Below is a sample program and 3D. We thank you for your cooperation.

3D image

if (variety = 1)
[
 set-current-plot "Color-Time"
 set-current-plot-pen "CT"
]
plotxy ticks (***add it here***)

      

+3


source to share


1 answer


This should work:

plotxy ticks count turtles with [color = red]

      

Or, if you always print every tick (including the 0 tick), just:



plot count turtles with [color = red]

      

Note that if you put the plotting code inside the chart itself, and not on the Code tab, you don't need set-current-plot

and at all set-current-plot-pen

. The usual way to do a stub in NetLogo is to place code on graphs, then that code is run automatically using reset-ticks

and tick

on the Code tab.

+2


source







All Articles