如何在同一个窗口中绘制多个分布?

问题描述 投票:0回答:1

我正在尝试绘制不同类型海龟的年龄分布。我使用绘图界面并添加一支笔来绘制整个海龟种群的年龄分布。我将该笔的绘图更新命令设置为

histogram [ ticks - birth-tick ] of turtles

此外,我将 绘图设置命令 设置为

set-histogram-num-bars 50

现在,当我为海龟子群添加笔时,例如

histogram [ ticks - birth-tick ] of turtles with [ shape = "circle" ]
,分布会在
y = 0
处给出一条平线。

如果我颠倒两支笔的顺序,则只有子群体会正确显示,而整个群体则不会。因此,似乎只有第一支笔被正确评估。

这是一个可能的线索:在评估我使用

count
的不同分布时,我确实设法获得了不同子群体的多个分布,例如
histogram [count link-neighbors] of turtles
histogram [count link-neighbors] of turtles with [ shape = "circle" ]
。另外,这里好像我不需要设置
set-histogram-num-bars 50

netlogo
1个回答
3
投票

如果你看到一条线,我猜你只是为那支笔选错了

mode
。在我看来,在代码选项卡中编写更全面的绘图作为自己的过程会更容易。

这里是一个示例,假设您使用名为“第一”和“第二”的两支笔创建了一个名为“图 1”的图:

to setup 
  clear-all
  create-turtles 10 [
    set shape "circle"
    setxy random-xcor random-xcor
  ]
  create-turtles 10 [
    setxy random-xcor random-xcor
  ]
end

to plot-hist
  set-current-plot "plot 1" ; choose plot by its name
  clear-plot
  
  set-current-plot-pen "first" ; choose pen by its name
  set-plot-pen-mode 1 ; for bar
  set-histogram-num-bars 2 ; defin number of bars
  histogram [ xcor ] of turtles ; define what to plot

  set-current-plot-pen "second"
  set-plot-pen-mode 1 ; for bar
  set-histogram-num-bars 5
  histogram [ xcor ] of turtles with [shape = "circle"]
end
© www.soinside.com 2019 - 2024. All rights reserved.