plotnetlogoticker

Netlogo plot shows wrong ticks


I have a model that has CO2 emissions made by cars. From what I have gathered, I think it is working correctly. But when I plot the emissions, the XX axis shows the double of ticks that the model has ran. Each tick change in the plot has a kind of plateau (see Image 1). In this example, I ran the model with 10 ticks but the plot gives me 20 ticks. When I export the plot to csv, my suspicions are confirmed (see Image2). As far as I can see, the emission calculation is correct. It's just the "extra" ticks that's driving me crazy.

I've ran through the model and I can't see anything that's obviously wrong. Nevertheless, my Netlogo coding is weak, at best. I have distance calculation with:

let distance_this_tick speed
set distance-traveled distance-traveled + distance_this_tick

and each forward in the drive procedure is "speed".


Solution

  • This sounds like your "plot" statement is being executed 2 times per tick. Remember that the "plot" command increments the X value by 1 each time it is executed.

    Make sure that the plot statement is not inside a procedure or "ask" statement that would cause it to be executed more than once per tick. It normally works well to put the plot statement near the end of "go" procedure:

    to go
      tick
      ...
      plot emissions
    end
    

    Another possible explanation is that you have a plot statement in your code and another one in the plot widget itself on the Interface. If you have a "plot" statement in your code, edit the plot on the Interface and make sure the "Pen update commands" is blank.

    (Or if your plot commands are only in the plot widget and not in your code, make sure the "Pen update commands" just say "plot emissions" and do not include "ask" etc. that would cause the plot to be updated twice.)