Rolling Plot Example
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This shows how to make a "rolling" plot, in which only the last n time steps of data are displayed.
HOW IT WORKS
In the plot, the set-plot-x-range
command is used to set the visible range to only the most recent 800 ticks.
Note that we change the range after plotting, not before. That's because if autoplot is on, plotting a point could change the range, after which we need to change it again. (It is not possible to turn autoplot on for only one axis, so if we want it for the y-axis, we must live with having it on the x-axis too.)
Also note that setting the x range doesn't cause old data to be discarded. Even if the old data isn't visible on the screen, it can be revealed by changing the x range to something wider, or by exporting the plot.
RELATED MODELS
Plotting Example
Comments and Questions
to setup clear-all create-turtles 1 [ ; create one turtle set color red set xcor (2 + min-pxcor) ; set the turtle's initial position and heading set ycor 0 set heading 0 set size 5 ; easier to see this way pen-down ] reset-ticks end to go ask turtles [ fd (pi * (max-pycor - 2) / 180) / 8 ; move in a circle rt 0.125 ] tick end ;; the actual plotting code is in the plot itself, in the Interface tab ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Rolling Plot Example.png | preview | Preview for 'Rolling Plot Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.