使用gnuplot在一条曲线中绘制多个(x,y)坐标 [英] plotting multiple (x,y) co-ordinates in a single curve with gnuplot

查看:80
本文介绍了使用gnuplot在一条曲线中绘制多个(x,y)坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单个图形中绘制多个(x,y)坐标.假设我有一个数据文件,其内容如下:

Hi I want to plot multiple (x,y) coordinates in a single graph. Say I have a data file which has the contents 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.7    0.9

我可以在此文件中添加更多数据吗,

could I have a some more data in this file like,

 x     y       x1     y1
0.0    0.5    0.04    0.7   
0.12   0.1    0.08    0.74 
0.16   0.4    0.12    0.85
0.2    0.35   0.16    0.9
0.31   0.8    0.2     0.53
0.34   0.6    0.24    0.31
0.38   1.0    0.28    0.87
0.46   0.2    0.32    0.20
0.51   0.7    0.36    0.45
0.7    0.9    0.4     0.64

并在gnuplot上绘制图形,其中(x,y)和(x1,y1)都在一条曲线中?谢谢你.

and plot the graph on gnuplot where (x,y) and (x1,y1) would all be in a single curve? Thank you.

推荐答案

gnuplot只能绘制列格式数据.也就是说,在按如下所示转置数据后,必须将其绘制在其中:

gnuplot can only plot column format data as far as I know. That said, you will have to plot it in after transpose your data as follows:

x  0.000000 y  0.500000 x  0.120000 y  0.100000  ...
x1 0.040000 y1 0.700000 x1 0.080000 y1 0.740000  ...

plot data us 1:2, data us 3:4, data us 5:6.

要转置数据,可以将程序更改为以这种方式编写,也可以使用以下awk脚本:

To transpose the data, you can either change your program to write it in this way, or use following awk script:

awk '{for (i=1;i<=NF;i++) arr[NR,i]=$i;} END{for (i=1;i<=NF;i=i+2) {for (j=1;j<=NR;j++) {printf "%f %f ",arr[j,i],arr[j,i+1]} print ""}}' datafile

这篇关于使用gnuplot在一条曲线中绘制多个(x,y)坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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