Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gnuplot 使用GNU plot在同一图形上打印.dat文件和.csv文件中的数据_Gnuplot - Fatal编程技术网

Gnuplot 使用GNU plot在同一图形上打印.dat文件和.csv文件中的数据

Gnuplot 使用GNU plot在同一图形上打印.dat文件和.csv文件中的数据,gnuplot,Gnuplot,我有两种格式的数据文件,一种是.csv,另一种是.dat。是否可以将这两个文件中的数据绘制在同一图表上 为了从.dat文件打印数据,我使用了以下命令: plot "test.dat" using 1:2 with lines set datafile separator ',' plot "test1.csv" using 1:2 我打算使用连续线绘制.dat文件中的数据。这是我能够做到的 为了绘制.csv文件中的数据,我使用了以下命令: plot "test.dat" using 1:2

我有两种格式的数据文件,一种是.csv,另一种是.dat。是否可以将这两个文件中的数据绘制在同一图表上

为了从.dat文件打印数据,我使用了以下命令:

plot "test.dat" using 1:2 with lines
set datafile separator ','
plot "test1.csv" using 1:2
我打算使用连续线绘制.dat文件中的数据。这是我能够做到的

为了绘制.csv文件中的数据,我使用了以下命令:

plot "test.dat" using 1:2 with lines
set datafile separator ','
plot "test1.csv" using 1:2
我想用虚线绘制.csv文件中的数据。i、 例如,类似于这个“---”的东西

.dat文件中的一行数据是

-8.14257e-01 2.04276e+00 0.00000 E+00

而from.csv是

3.12487-03,1.58743-03


你能做的一件事就是回复

plot "test.dat" u 1:2 w lines
set datafile separator ','
replot "test.csv" u 1:2
这将在绘图中添加第二行。您可以做的另一件事是指定输入格式

set datafile separator ','
plot "test.dat" u 1:2 "%lf %lf %lf", "test.csv"
注:在Gnuplot 5.2中,我可以在不指定任何内容的情况下绘制这两个文件

plot "test.dat", "test.csv"
他们都出现了

格式规范的文档(
帮助使用
,):

语法:
使用{:{:…}{'format'}打印“文件”

如果指定了格式,则使用C库的“scanf”函数读取每个数据文件记录。否则,记录被解释为由数据列(字段)组成,数据列(字段)由空格(空格和/或空格)分隔,但请参见数据文件分隔符


您可以指定多个字符来设置数据文件分隔符。如果列之间用空格或逗号分隔,请使用

set datafile separator " ,"
plot "test.dat", "test1.csv"

请注意,这仅在列由单个空格分隔时有效。不过,有一个简单的变体可能会有用。

我认为您需要提供有关这些文件的更多信息。你能用gnuplot绘制其中任何一个的数据吗?我是gnuplot的新手。是的,我能够分别绘制.csv和.dat中的数据。但是我不知道如何在同一个图形上绘制它们。也许你可以在你的问题中添加你运行的用于单独绘制它们的plot命令。然后还包括一个描述,说明当它们一起打印时,您希望打印的外观。您是否尝试使用1:2打印“test1.csv”,使用1:2 w线打印“test.dat”?是的。但是“test1.csv”中的数据没有打印,因为这需要
设置数据文件分隔符',
而如果我使用
设置数据文件分隔符',“
则没有打印“test.dat”中的数据。
plot“test.dat”,“test.csv”
正在打印某些内容,但不正确(gnuplot 5.2)。谢谢。因为我很少有csv文件,所以我将改变它:
plot“test.dat”,“test.csv”u 1:2“%lf,%lf,%lf”
。因此,实际上不需要使用
设置数据文件分隔符
!这应该是第一个答案。但是,如果逗号分隔文件中的字段内部包含空格,那么这将不起作用。。。。只有当
test.dat
正好有一个空格作为列分隔符时,它才能工作。多个空格不起作用。@theozh确实,我没有意识到这一点。