Gnuplot - plot position (xyz) and time data in a given space (e.g. field) with pause
Can the following be done in gnuplot? If so, how?
I have data for time vs position (x, y, z) in a table with t, x, y, z as headers.
I would like to know if I can somehow plot the same time compared to the position of the particle inside a predefined space, with a pause after each time step; so I can see the evolution of the position of the particles over time. I would also like to know if I can draw a continuous line from the previous position to the current position so that I can really see the trace of my past.
Sample data:
Let's say the predefined space is a 10x10x10 field and my particle has the following positions for 3 seconds.
t x y z
0 1 2 3
1 2 3 4
2 3 4 5
3 4 5 6
How I see particle tracking! my idea is that if I can pause the graph of each time step a little, it looks like an animation that I can just capture with a screen capture software ...
FREE, this data can be animated with gnuplot too
Is there any other software that does this more efficiently and / or gracefully if gnuplot is not the right tool !?
Any help would be appreciated!
Thank.
source to share
Create a file main.gp
and run gnuplot main.gp
or load "main.gp"
shell gnuplot. The output is at point.gif. Documentation
http://www.gnuplot.info/documentation.html
Also you can type help
in gnuplot wrapper.
main.gp
set term gif animate delay 30 size 400, 400
set output "point.gif"
do for [n=1:4] {
splot [0:7][0:7][0:7] "data" u 2:3:4 every :::::n w lp t sprintf("n=%i", n)
}
<strong> data
t x y z
0 1 2 3
1 2 3 4
2 3 4 5
3 4 5 6
EDIT: I switched to iteration as @mgilson suggested .
source to share
I realized that the code in each case should be :: n instead of 5 colons. NOW if I wanted 2 separate files to be read and colored differently, what would I do? I have this and it colors 2 plots in red .. what if I wanted red and blue.? do for [n = 1: 46] {splot [0: 0.002] [0: 0.0025] [0: 0.001] "data3.txt" u 2: 3: 4 every :: nw lp t sprintf ("n =% i ", n) splot [0: 0.002] [0: 0.0025] [0: 0.001]" data4.txt "u 2: 3: 4 each :: nw lt 1 lw 1 pt 1 ps 1 lc rgb" blue "sprintf ( "n =% i", n)} ### the second splot throws an error .. and if the same code is used as for splots-wont wrk
source to share