Merging multiple data files to plot in a single graph

gnuplot

extending the question I had asked earlier which can be found here, plotting multiple (x,y) co-ordinates in a single curve with gnuplot. I am trying to plot the bezier curves in gnuplot using 2 different files. Each (x,y) from the first file forms a bezier curve passing through the points from the second file. The first file has the co-ordinates like the following:

 x      y  
0.0    0.5     
0.12   0.1    
0.16   0.4    
0.2    0.35   
0.31   0.8    
0.34   0.6   
0.38   1.0    
0.46   0.2   
0.51   0.7    
0.69   0.9    

The second file has the co-ordinates as the following:

 x      y
0.00   0.7
0.04   0.74073082208
0.08   0.85926917792 
0.12   0.9 
0.16   0.9
0.2    0.9  
0.24   0.749720623086
0.28   0.874229601255
0.32   0.74073082208
0.36   0.8 
0.4    0.721178508605 
0.44   0.878821491395
0.48   0.761772990545
0.52   0.700774803388
0.56   0.723771273415
0.6    0.789508073675
0.64   0.864014272269
0.68   0.896743348931

Now, how do I merge these two files to plot a single graph. These two files don't have the same number of rows, but I guess that doesn't matter. The first curve would be between (x1,y1) and (x2,y2) from the first file which would continue till (x10,y10). In the curve between (x1,y1) and (x2,y2); the points (x1,y1), (x2,y2) and (x3,y3) from the second file lie.

I followed this link http://t16web.lanl.gov/Kawano/gnuplot/datafile3-e.html to sort and concatenate the two files but got some weird lines which is totally wrong. These values should actually plot Bezier curves but not getting the graph. I have written the following gnuplot script to plot the concatenated data:

set term x11 persist
set title "Animation curves"
set xlabel "Time (secs.)"
set ylabel "Parameter"
set x2label "Phoneme1" offset -35
set pointsize 2
set key off
set style line 2 lt 0 lc 1 lw 2
set xrange [0.0:1.0]
set yrange [0.0:1.3]

plot [0.0:0.8] "< cat -n file1.dat" u 1:2 smooth csplines ls 1, "" u 1:(0.0):(0):(1.3) w vectors nohead ls 2, "" u ($1+0.005):(1):(sprintf("P %d", $0)) w labels, \
           "file1.dat" u 1:2 with points, \
           "file2.dat" u 1:2 with points, \    

I got the following error:

plot "< cat -n file1.dat" u 1:2 smooth csplines ls 1, "" u 1:(0.0):(0):(1.3) w vectors    nohead ls 2, "" u ($1+0.005):(1):(sprintf("P %d", $0)) w labels, "file1.dat" u 1:2 with points, "file2.dat" u 1:2 with points,                  
                          ^
"plot.gp", line 21: Cannot smooth: no data within fixed xrange!

Best Answer

The script below works on my machine. Maybe this is even what you are looking for...

set term x11 persist
set title "Animation curves"
set xlabel "Time (secs.)"
set ylabel "Parameter"
set x2label "Phoneme1" offset -35
set pointsize 2
set key off
set style line 2 lt 0 lc 1 lw 2
set xrange [0.0:1.0]
set yrange [0.0:1.3]

plot [0.0:0.8] "< cat file1.dat file2.dat | sort -n" u 1:2 smooth csplines ls 1, \
                         "" u 1:(0):(0):2 w vectors nohead ls 2, \
                         "" u ($1 + 0.005):(1):(sprintf("P %d", $0)) w labels, \
                         "file1.dat" u 1:2 w p, \
                         "file2.dat" u 1:2 w p 
Related Topic