如何在 netlogo 中绘制 x 轴上海龟分布的直方图

How to plot a histogram of distribution of turtles on x-axis in netlogo

在我的模型中,代理在移动。例如,

breed [guys guy]
breed [infos info]

to setup
create-guys 50 [setxy random-xcor random-ycor]
create-infos 50 [setxy random-xcor random-ycor]
end

to go
ask guys [create-link-to one-of infos
if any? my-links [setxy mean [xcor] of link-neighbors mean [ycor] of link-neighbors ]]
end

我想画一个直方图显示海龟的分布 直方图的x轴两端代表min-pxcor和max-pxcor,而直方图的y轴代表该pxcor上的海龟数量。

这个我试过了。

histogram [count guys-on patch pxcor pycor] of guys

但我需要的是每个 pxcor 的所有 pycor 的平均值。

如果您想要的是计数分布的直方图 - x 轴为 pxcor,y 轴为具有该 pxcor 的补丁上的人数,那么您可以这样做:

histogram [pxcor] of guys

因为海龟可以访问它们所在的补丁的变量。

我想这就是您想要从您的描述中得到的。但是后来你问了 pyxor 的平均值,我看不出这有什么关系。