I noticed that my tick counter does not show the same as the time in my plots. It seems 1 tick is roughly equal to 2 units of time on my graphs.
I would have thought that the time in plots was related to ticks, but this doesnt seem to be the case.
How does these two relate?
If you want absolute control over both coordinates of the points you are plotting, use plotxy instead of plot.
If you just use plot, then the x coordinate just ends up being "how many times I've called plot". If you always call plot exactly once per tick, that will equal the number of ticks.
Perhaps you are, without realizing it, calling plot either more or less frequently than that...? Note that it's possible (and recommended) to have all of your plotting code inside plots, but you might also (or instead) have plotting code in the Code tab.
If you can tell us more about how you define your time unit in your graph we might be able to help you more, but as far as I know a tick 's length is all dependent on computation and its the time taken to iterate through your Go (or whenever you defined tick from start to end once! )
But you can use timer for measuring time taken after resetting timer in milliseconds :
http://ccl.northwestern.edu/netlogo/docs/dict/timer.html
In your problem, I think it's better to check interval in your plot, if it's anything other than 1 it means it does not update your plot every tick ,
Related
I'm trying to plot two turtle variables against each other in a scatterplot. I want this plot to update continuously, and erase the points from previous steps. I.e. I want one point to move to represent the variable values for one turtle throughout its lifetime, disappearing when it dies and these values equal zero.
This is my code for the pen update commands (isspecials is my turtle agentset)
ask isspecials [plotxy r invader-stride]
I tried adding
reset-plot-pens
to the end of it, but then nothing appears on the plot. I think it's almost as if I have to create a new pen for each turtle, but I can't tell. I'm really new to this, so if anyone has any suggestions I'd really appreciate it!
I tried adding
reset-plot-pens
to the end of it
Adding plot-pen-reset is the right idea! However, you need to add it before your plotting command.
The plot-pen-reset primitive erases everything that the plot pen has drawn. If you call it right after you plot, you don't get a change to see anything! Calling it just before plotting new stuff will ensure that the stuff you plotted in the previous tick has plenty of time to be seen.
Here is what you plot pen definition should look like:
I'm using GUIDE to display a plot within an axis that contains two data sets: the original signal and the average of the signal, but for some reason it seems to only plot one.
The axis is designated as m_graph and the data sets are avg and signal, which both share time.
plot(handles.m_graph, time,signal)
hold on
plot(handles.m_graph, time, avg)
When I compile the program, only the average is plotted. It seems to skip over the original signal or reset the axis. I've tried plotting just the signal so I know the data is fine.
I feel like I am missing something, maybe the set function?
Sorry my reasoning was a bit wrong; it applies to the current selected axes (it does not parent to the Figure).
However, using axes(h) followed by hold on or just hold(h,'on') will either switch the focus to the axes then turn hold on or turn hold on for a specified axes, respectively.
Is it possible to have plots that are updated at different time points?
My model looks like that (it is replicator dynamics):
to go
repeat 10 [do-something]
replicate
tick
end
Then I would like to have one plot that is updated on tick, just like usual, and the second one that is updated at do-something and then reset at tick.
I tried to find a solution in documentation but update-plots command updates ALL plots which is not what i want.
You can use the various manual plotting commands (eg plotxy, plot-pen-down, plot-pen-up) to explicitly plot things, see the plotting section of the user manual, but is often simpler to have the plot commands in the plot rather than the code.
To do it in the plot instead of code, you could change to a structure like this (if your full code is suitable):
to go
do-something
if ticks mod 10 = 0 [ replicate ]
tick
end
and use the automatic update of plots with tick. You would also use the if ticks mod 10 = 0 trick in the update section of your plot.
In the model I'm working on, ticks are months, and line plots are updated once every year, i.e. every 12 ticks. As ticks accumulate, the scale within the graph changes, of course, and the number in the lower right corner of the plot increases. This number reflects the number updates that have been made to the plot--i.e. the number of years. The number is the number of years that can be represented on the plot given its current scale.
Is there a way to change this number, without changing the rest of the plot, and without changing the idea that ticks are months? It would be convenient for this maximum x-axis value to show the number of months--i.e. ticks that could be displayed, even though the plot is only updated every 12 ticks.
Use the set-plot-x-range primitive. http://ccl.northwestern.edu/netlogo/docs/dictionary.html#set-plot-x-range
I have some energy 24 hour consumption data of many days.
Plotting a specific day gives me vertical axis of consumption and horizontal axis of time.
I would like to plot for lets say 1 year.
If I use "hold on/off" command, it plots all days together on top of each other.
How can i plot in a way that for the second day, the plots goes to the continue of the first plot (horizontal axis extends automatically)? So, when I have the complete plot, it shows 365 days of energy consumption based on hour. It's like the horizontal axis is repeating while the vertical axis is updating. I'm talking about MATLAB.
You can still use hold on and plot each day separately (if I understand your question properly, this is what you want, separate plotting). Simply make sure your x-axis values are correct. So e.g. if you have one measurement value per hour, the plot day 1:
plot(1:24,valDay1,'k-')
then for day 2:
plot(25:48,valDay2,'r-')
etc. This will line things up correctly. Also, consider using a datetime as x axis values
So, I found my solution which is very simple. I don't know how it didn't occur earlier.
I just had to use ";" and that's it.
Like this:
DAY=[day1;day2;day3]
plot(DAY)