Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Plot Netlogo如何制作有序直方图_Plot_Histogram_Netlogo - Fatal编程技术网

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”。)

以下是它的工作原理:

  • table:group agents
    将提供一个表,其中键是物种id,值是具有相应物种id的鸟类的agentset
  • table:values
    放弃键,只留下一个agentset列表
  • map count
    提取每个代理集中的鸟类数量,为您留下一个计数列表
  • 反向排序计数
    将列表从最大值排序到最小值
  • foreach(反向排序计数)绘图
    为每个数字绘制一个条形图

您将无法直接使用
直方图
命令执行此操作,但
扩展提供了方便的
表:组代理
报告程序,可让您相对轻松地执行此操作

只需将其放入绘图笔更新命令:

plot-pen-reset
let counts map count table:values table:group-agents birds [ species ]
foreach (reverse sort counts) plot
(不要忘记将笔模式更改为“Bar”。)

以下是它的工作原理:

  • table:group agents
    将提供一个表,其中键是物种id,值是具有相应物种id的鸟类的agentset
  • table:values
    放弃键,只留下一个agentset列表
  • map count
    提取每个代理集中的鸟类数量,为您留下一个计数列表
  • 反向排序计数
    将列表从最大值排序到最小值
  • foreach(反向排序计数)绘图
    为每个数字绘制一个条形图