【问题标题】:How to plot a histogram of distribution of turtles on x-axis in netlogo如何在 netlogo 的 x 轴上绘制海龟分布的直方图
【发布时间】:2021-03-08 18:52:22
【问题描述】:

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

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 的平均值。

【问题讨论】:

    标签: histogram netlogo


    【解决方案1】:

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

    histogram [pxcor] of guys
    

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

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

    【讨论】:

    • 你是对的。这对我帮助很大!我提到了 pycor,因为一个 pxcor 上有很多 pycor。所以我认为应该有一个进一步的过程来处理一个特定的 pxcor 上的多个 pycor。显然,我错了。谢谢。
    • @nicetomeetu 欢迎来到 SO;如果答案解决了您的问题,请接受 - 请参阅What should I do when someone answers my question?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-02
    • 2014-04-19
    • 1970-01-01
    • 1970-01-01
    • 2016-01-05
    • 1970-01-01
    • 2015-01-07
    相关资源
    最近更新 更多