Reputation: 417
I am trying to plot a graph that shows the variables of all agents of one breed. Although the number of agents is rather small, I think there must be a more elegant way than creating a pen for every agent. Is there?
Upvotes: 2
Views: 1070
Reputation: 14972
Elegance, here, depends on what exactly you want to do. It can be perfectly legitimate to create one plot pen per turtle, using create-temporary-plot-pen
. Among advantages, it means that you can give each plot pen a name and show a legend on your plot.
That being said, it's also very easy to use a single pen for all your agents. Suppose you have multiple turtles, of different colors, and you want to plot their sizes. You can put something like this in a pen's "update commands":
ask turtles [ set-plot-pen-color color plotxy ticks size ]
This will change the pen to the color of each turtle and plot a single point for that turtle. Just be sure to set your pen to "point" mode in the advanced pen options.
Also notice the use of plotxy
instead of just plot
, allowing you to specify an x coordinate instead of relying on the "auto advance" behavior of plot
.
Upvotes: 4