Jane Aminato
Jane Aminato

Reputation: 23

NetLogo Histogram - Distribution of visits

I've a simple problem.

In my code there are some patches that contain food. I computed the # of visits for each one of these "resources". Now I want to put in a histogram the # of visits for each one of these "resource-patches" .

If I write in the GUI:

histogram [visits] of resource-patches

It plots me something strange.

This is because, usually, you put the "x" values in the brackets [ ] of the patches-own attribute. Instead, I want that

-in the "x-axis" there are the labels (for example) of the resource-patches (or their amount of food) whereas

-in "y-axis" I want the #of visits for each one of the resource-patches.

I'm struggling since yesterday but I can't find a solution.

Thank you in advance guys!

Upvotes: 1

Views: 418

Answers (1)

mattsap
mattsap

Reputation: 3806

A histogram only takes in the values for the x-axis. The y-axis will always be the number of occurrences of x in the list provided. For you, it'll plot the frequency of each of yours visits.

If your visits list is [1 1 3 5 2 3 4 5]

You'll see a histogram of

x, y
1->2
2->1
3->1
4->1
5->2

I think you may want to look at another plotting tool if this is not what you want.

Upvotes: 2

Related Questions