Konty
Konty

Reputation: 25

Plotting variables from a list

I am trying to plot the velocity distribution of the turtles in my model. The velocity vector vi of each turtle is contained in a list (coordinates vix, viy) I am not sure if using

plot max item 0 [vi] of turtles 

is showing what I really want which is the maximum velocity of all turtles. I wonder if max-one-of primitive would be better? but when I use

plot max-one-of turtles item 0 [vi] 

of course, I received the error expected a literal value. As it is a list I do not know how to rewrite item 0 [vi] to be recognized by the plot.

What I am doing now is creating a monitor using max-one-of as I think this will do what I want

max-one-of adults [item 0 vi]

but the monitor is showing me (adult 24) and it's okay, I have checked that from all turtles in the simulation for that particular tick, adult 24 has the higher velocity but I want the monitor to show me the velocity value (number) not the who number. How can I do this?

I guess after making the monitor do what I want I can copy that piece of code into the plot to create the graph.

I thank you in advance for your thought and recommendations =)!

Upvotes: 1

Views: 110

Answers (1)

Seth Tisue
Seth Tisue

Reputation: 30453

If I understand the question correctly, then this should do the trick:

plot max [item 0 vi] of turtles

If you were to write this with max-one-of, it would come out as:

let winner max-one-of turtles [item 0 vi]
plot [item 0 vi] of winner

but as you can see, max-one-of isn't really helping.

Upvotes: 2

Related Questions