Plot Netlogo如何制作有序直方图
我想做一个海龟变量的柱状图,但用从大到小的顺序排列,我做了一个例子Plot Netlogo如何制作有序直方图,plot,histogram,netlogo,Plot,Histogram,Netlogo,我想做一个海龟变量的柱状图,但用从大到小的顺序排列,我做了一个例子 breed [birds bird] ; living birds birds-own [ species] to setup ask n-of 2000 patches [ sprout-birds 1 [ set shape "circle" set species random max-birds-species
breed [birds bird] ; living birds
birds-own [ species]
to setup
ask n-of 2000 patches [
sprout-birds 1 [ set shape "circle"
set species random max-birds-species
set color scale-color white species ( max-birds-species + 1 ) 0]
]
reset-ticks
end
to go
ask birds [
ifelse random-float 1 > gr-birds
[ die ]
[
let target one-of neighbors4 with [not any? birds-here]
if target != nobody [
hatch-birds 1 [ move-to target ]
]
]
]
tick
end
然后,如果我绘制直方图,它不是按频率排序的,我想看到最常见的物种在左边和下降
您无法直接使用
直方图
命令执行此操作,但表
扩展提供了方便的表:组代理
报告程序,可让您相对轻松地执行此操作
只需将其放入绘图笔更新命令:
plot-pen-reset
let counts map count table:values table:group-agents birds [ species ]
foreach (reverse sort counts) plot
(不要忘记将笔模式更改为“Bar”。)
以下是它的工作原理:
将提供一个表,其中键是物种id,值是具有相应物种id的鸟类的agentsettable:group agents
放弃键,只留下一个agentset列表table:values
提取每个代理集中的鸟类数量,为您留下一个计数列表map count
将列表从最大值排序到最小值反向排序计数
为每个数字绘制一个条形图foreach(反向排序计数)绘图
直方图
命令执行此操作,但表
扩展提供了方便的表:组代理
报告程序,可让您相对轻松地执行此操作
只需将其放入绘图笔更新命令:
plot-pen-reset
let counts map count table:values table:group-agents birds [ species ]
foreach (reverse sort counts) plot
(不要忘记将笔模式更改为“Bar”。)
以下是它的工作原理:
将提供一个表,其中键是物种id,值是具有相应物种id的鸟类的agentsettable:group agents
放弃键,只留下一个agentset列表table:values
提取每个代理集中的鸟类数量,为您留下一个计数列表map count
将列表从最大值排序到最小值反向排序计数
为每个数字绘制一个条形图foreach(反向排序计数)绘图