user3369125
user3369125

Reputation: 165

Creating multiple plots on the same Graph?

In my code i have a variable called hops owned by the breed ants.

             ants-own 
            [
                hops
                distance-gone
                distance-to-go
                target-node
                current-node
            ]

I want to plot the hops against the time ( ie when it takes 1st hop , it plots 1 against time n likewise) for each ant. In doing so, i should have n number of graph lines on the same plot where n is my number of ants).

i implemented it using the following code snippet, but getting only one line of graph.

     to do-plot

      set-current-plot "Hop Count"
      let i 0
      ask ants 
       [
         set-current-plot-pen (word who)
         set-plot-pen-color i + 15
         plot  hops 

       ]
      end

It would be better if different ants graph gets plotted in diffrent color.

Upvotes: 2

Views: 1249

Answers (1)

Bryan Head
Bryan Head

Reputation: 12580

At setup, you need to create a plot pen for each ant using create-temporary-plot-pen (word who). Are you doing this?

Also, I don't think the color line is going to turn out how you want it. In NetLogo, the main colors are 5, 15, 25, 35, and so forth. The other numbers are shades of those colors. When I'm doing something like this, I would usually do something like 10 * ( who mod 14 ) + 5. There are 14 different colors, so who mod 14 keeps the color number in range. You can get repeated colors this way, but it's usually not too bad.

Upvotes: 3

Related Questions