合并多个数据文件以在单个图中绘制 [英] merging multiple data files to plot in a single graph

查看:81
本文介绍了合并多个数据文件以在单个图中绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

扩展了我先前提出的问题,可以在这里找到,

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

现在,如何合并这两个文件以绘制单个图形.这两个文件没有相同的行数,但是我想那没关系.从第一个文件开始,第一条曲线将位于(x1,y1)和(x2,y2)之间,该曲线将持续到(x10,y10).在(x1,y1)和(x2,y2)之间的曲线中;第二个文件中的点(x1,y1),(x2,y2)和(x3,y3)位于.

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.

我点击了此链接 http://t16web.lanl.gov/Kawano /gnuplot/datafile3-e.html 对两个文件进行排序和连接,但出现了一些奇怪的行,这是完全错误的.这些值实际上应该绘制Bezier曲线,但不能得到图形.我编写了以下gnuplot脚本来绘制串联的数据:

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, \    

我遇到以下错误:

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!

推荐答案

以下脚本可在我的计算机上使用.也许这就是您正在寻找的东西...

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 

这篇关于合并多个数据文件以在单个图中绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆