From an answer given here Gnuplot 3d time animation from data file I changed it a bit adding a filedata 2, now the problem is i have a filedata with
column1 column2 column3 column4
time x y z
0 54 89 787
0.15 90 676 345
0.70 4593 34 387
3.78 59 37 904
and so on with other time positions data (actually in my .dat file I didn't write time x y z ,only the values).
What I'd like to do is to take column 1 values and put its values in place of .j
in 'time'.j
.
Is there a way to do it?
# define fixed axis-ranges
set xrange [-1:1]
set yrange [0:20]
set zrange [-1:1]
# filename and n=number of lines of your data
filedata = 'data.dat'
n = system(sprintf('cat %s | wc -l', filedata))
do for [j=1:n] {
set title 'time '.j
splot filedata1 u 2:3:4 every ::1::j w l lw 2, \
filedata1 u 2:3:4 every ::j::j w p pt 7 ps 2,\
filedata2 u 2:3:4 every ::1::j w l lw 2, \
filedata2 u 2:3:4 every ::j::j w p pt 7 ps 2
}
Actually as of now I don't know how to put it to work.
To summarize what I've understood from your question:
Comments:
stats
(check help stats
). With this gnuplot-only and platform-independent, unlike your n = system(sprintf('cat %s | wc -l', filedata))
0
, e.g. every ::0::j
. But since you have a headerline this line will not be plotted because it is text data.with labels
. With this you can plot the value from column 1 somewhere as label, here at x,y,z ... u (7):(10):(10) ...
.Data:
SO74583831_1.dat
t x y z
0 1.0 2.0 3.0
0.15 2.0 5.0 4.0
0.70 5.0 3.0 5.0
3.78 7.0 7.0 6.0
5.13 5.0 4.0 7.0
7.45 3.0 4.0 8.0
10.99 1.0 1.0 9.0
SO74583831_2.dat
x y z
4.0 4.0 9.0
7.0 5.0 8.0
6.0 6.0 7.0
3.0 3.0 6.0
2.0 2.0 5.0
5.0 1.0 4.0
9.0 3.0 3.0
Script:
### plot two animated trajectories, 2nd file without time
reset session
FILE1 = "SO74583831_1.dat"
FILE2 = "SO74583831_2.dat"
stats FILE1 u 0 nooutput
N = STATS_records
set xrange[0:10]
set yrange[0:10]
set zrange[0:10]
set key noautotitle
set xyplane at 0
set terminal gif animate delay 60
set output "SO74583831.gif"
do for [j=0:N-1] {
splot FILE1 u 2:3:4 every ::0::j w l lw 2 lc "red", \
'' u 2:3:4 every ::j::j w p pt 7 ps 2 lc "red" ti "Particle 1", \
'' u (7):(10):(10):(sprintf("Time: % 6.2f",$1)) every ::j::j with labels left, \
FILE2 u 1:2:3 every ::0::j w l lw 2 lc "blue", \
'' u 1:2:3 every ::j::j w p pt 7 ps 2 lc "blue" ti "Particle 2", \
}
set output
### end of script
Result: