plotnetlogo

Scatter plot not updating propertly


I have a small problem updating a scatter plot.

Currently I have as the initialization command

ask small-agricultors [plotxy economic global]

For the updating i have the same code

ask small-agricultors [plotxy economic global]

However, the graph is not updating as I wanted because I thought that Updating meant that it would move the point to the new position, instead it placed new points (Top of the image) How do I tell netlogo to just move the points? or delete the previous ones?

Scatter plot. Here I wanted to see the points move, instead I got a ton of points!


Solution

  • the clear-plot command is probably what you are looking for (see here). Note that: "This command will produce a runtime error if the current plot has not been set.", so you will have to set the desired plot with set-current-plot if you don't do it already (see here).

    to plotting
      set-current-plot "plot 1"
      clear-plot
      set-current-plot-pen "default"
      set-plot-pen-mode 2 
    
      ask n-of 5 patches [plotxy pxcor pycor]
    end