情节乌龟vs能量 [英] plot turtles vs energy

查看:104
本文介绍了情节乌龟vs能量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好netlogo社区

Hello netlogo community

我有一个简单的模型,其中有100只海龟,每只都有一个称为能量的变量. 我该如何绘制一个图表来绘制世界上每只乌龟的能量 我是说: x轴每只乌龟 与乌龟相关的y轴能量

I have a simple model with 100 turtles and each one has a variable called energy. How can I draw a graph that plots for each turtle in the world his energy I mean: x-axis each turtle y-axis energy associated to the turtle

抱歉,我认为这是一个简单的问题,但我可以弄清楚该怎么做. 理想情况下,我想要一个如下的直方图:

Sorry I think is an easy question but I can figure out how to do it. Ideally I would like an histogram like the following:

直方图

推荐答案

NetLogo histogram 命令不允许您逐个绘制每个值,但是自己编写代码并不难.

The NetLogo histogram command won't allow you to plot each value individually, but it's not too hard to code it yourself.

假设您有一个包含以下代码的模型:

Supposing you have a model with the following code:

turtles-own [ energy ]
to setup
  clear-all
  create-turtles 100 [ set energy random 100 ]
  reset-ticks
end

您可以使用定义如下的笔添加绘图:

You can add a plot with a pen that is defined like this:

(别忘了将笔模式设置为"Bar"!)

(Don't forget to set the pen mode to "Bar"!)

要获得这样的情节:

请注意,这使用了新的NetLogo 6.0匿名过程语法.在NetLogo< = 5.3.1中,您将使用[ ask ? [ plot energy ] ]而不是[ [t] -> ask t [ plot energy ] ].

Note that this uses the new NetLogo 6.0 anonymous procedure syntax. In NetLogo <= 5.3.1, you'd use [ ask ? [ plot energy ] ] instead of [ [t] -> ask t [ plot energy ] ].

还请注意, sort 会对您的海龟进行排序who号.如果您希望使用其他顺序,请使用 sort-on .

Also note that sort will sort your turtles by who number. Use sort-on if you prefer a different order.

这篇关于情节乌龟vs能量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆