使用 GNU plot 在同一图表上绘制来自 .dat 文件和 .csv 文件的数据
Plotting data from .dat file and .csv file on a same graph using GNU plot
我有两种格式的数据文件,一种是.csv,另一种是.dat。是否可以将这两个文件的数据绘制在同一个图表上?
为了绘制 .dat 文件中的数据,我使用了以下命令:
plot "test.dat" using 1:2 with lines
我打算使用实线绘制 .dat 文件中的数据。这个我能做到。
为了绘制 .csv 文件中的数据,我使用了以下命令:
set datafile separator ','
plot "test1.csv" using 1:2
我想使用虚线绘制 .csv 文件中的数据。即类似于此“- - - - - -”的内容
.dat文件的一行数据是
-8.14257e-01 2.04276e+00 0.00000e+00
来自 .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"
他们都出现了。
格式规范文档(help using
、page 98):
Syntax: plot ’file’ using <entry> {:<entry> {:<entry> ...}} {’format’}
If a format is specified, it is used to read in each datafile record using the C library ’scanf’ function. Otherwisethe record is interpreted as consisting of columns (fields) of data separated by whitespace (spaces and/ortabs), but see datafile separator.
您可以为 set datafile separator
指定多个字符。如果列由 space 或逗号分隔,请使用
set datafile separator " ,"
plot "test.dat", "test1.csv"
请注意,这仅在列由单个 space 分隔时有效。尽管如此,拥有一个简单的变体可能还是有用的。
我有两种格式的数据文件,一种是.csv,另一种是.dat。是否可以将这两个文件的数据绘制在同一个图表上?
为了绘制 .dat 文件中的数据,我使用了以下命令:
plot "test.dat" using 1:2 with lines
我打算使用实线绘制 .dat 文件中的数据。这个我能做到。
为了绘制 .csv 文件中的数据,我使用了以下命令:
set datafile separator ','
plot "test1.csv" using 1:2
我想使用虚线绘制 .csv 文件中的数据。即类似于此“- - - - - -”的内容
.dat文件的一行数据是
-8.14257e-01 2.04276e+00 0.00000e+00
来自 .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"
他们都出现了。
格式规范文档(help using
、page 98):
Syntax:
plot ’file’ using <entry> {:<entry> {:<entry> ...}} {’format’}
If a format is specified, it is used to read in each datafile record using the C library ’scanf’ function. Otherwisethe record is interpreted as consisting of columns (fields) of data separated by whitespace (spaces and/ortabs), but see datafile separator.
您可以为 set datafile separator
指定多个字符。如果列由 space 或逗号分隔,请使用
set datafile separator " ,"
plot "test.dat", "test1.csv"
请注意,这仅在列由单个 space 分隔时有效。尽管如此,拥有一个简单的变体可能还是有用的。