来自数据文件的 gnuplot splot - 了解数据对齐
gnuplot splot from datafile - understanding data alignment
我无法理解 splot
如何处理数据文件中给定的点。使用存储在 datafile.dat
中的 example data from the gnuplot website 即
# The valley of the Gnu.
0 0 10
0 1 10
0 2 10
1 0 10
1 1 5
1 2 10
2 0 10
2 1 1
2 2 10
3 0 10
3 1 0
3 2 10
和运行在命令行
$ gnuplot
gnuplot> set xlabel "x"
gnuplot> set ylabel "y"
gnuplot> set zlabel "z"
gnuplot> splot "datafile.dat"
我明白了:
不过我预计:
- x 轴在 0 到 3 的范围内(似乎它使用第二个数据列代替)
- y 轴在 0 到 2 范围内,而不是 0 到 3
- 数据文件中第三列的 z 轴被完全忽略
我不确定你为什么会得到这个结果,以及如果你没有指定任何列,gnuplot 会将哪些列作为默认列。
但请检查 help splot
和 gnuplot homepage 上的示例并明确指定要绘制的列:
splot 'datafile.dat' u 1:2:3 with lines
或
splot 'datafile.dat' u 1:2:3 with pm3d
在我的环境中,将数据文件的分隔符设置为逗号,例如,重现了您面临的现象。
set datafile separator comma
set xlabel "x"
set ylabel "y"
set zlabel "z"
splot "datafile.dat"
我认为如果您 运行 在启动 gnuplot 后立即执行以下命令,然后 运行 与问题中相同的命令可能会起作用。
gnuplot> set datafile separator whitespace
出于某种原因,我怀疑您的 gnuplot 将空格以外的内容设置为数据文件的分隔符。
通过运行以下命令确保将哪个字符设置为分隔符。
gnuplot> show datafile separator
并确保您没有在“~/.gnuplot”(在类 UNIX 系统上)中设置 set datafile separator
。
加法:发生了什么
因为分隔符设置为逗号,所以只会读取每行数据中的第一个数字。这相当于下面的数据。
0
0
0
1
1
1
2
2
2
3
3
3
根据块数和内部行数,此数据被视为等效于 4x3 矩阵数据,给定数字被解释为 z 轴上的值。
0 0 0
1 1 1
2 2 2
3 3 3
使用 splot 绘制此数据会再现问题中的图形。
$data <<EOD
0 0 0
1 1 1
2 2 2
3 3 3
EOD
set xlabel "x"
set ylabel "y"
set zlabel "z"
splot $data matrix
我无法理解 splot
如何处理数据文件中给定的点。使用存储在 datafile.dat
中的 example data from the gnuplot website 即
# The valley of the Gnu.
0 0 10
0 1 10
0 2 10
1 0 10
1 1 5
1 2 10
2 0 10
2 1 1
2 2 10
3 0 10
3 1 0
3 2 10
和运行在命令行
$ gnuplot
gnuplot> set xlabel "x"
gnuplot> set ylabel "y"
gnuplot> set zlabel "z"
gnuplot> splot "datafile.dat"
我明白了:
不过我预计:
- x 轴在 0 到 3 的范围内(似乎它使用第二个数据列代替)
- y 轴在 0 到 2 范围内,而不是 0 到 3
- 数据文件中第三列的 z 轴被完全忽略
我不确定你为什么会得到这个结果,以及如果你没有指定任何列,gnuplot 会将哪些列作为默认列。
但请检查 help splot
和 gnuplot homepage 上的示例并明确指定要绘制的列:
splot 'datafile.dat' u 1:2:3 with lines
或
splot 'datafile.dat' u 1:2:3 with pm3d
在我的环境中,将数据文件的分隔符设置为逗号,例如,重现了您面临的现象。
set datafile separator comma
set xlabel "x"
set ylabel "y"
set zlabel "z"
splot "datafile.dat"
我认为如果您 运行 在启动 gnuplot 后立即执行以下命令,然后 运行 与问题中相同的命令可能会起作用。
gnuplot> set datafile separator whitespace
出于某种原因,我怀疑您的 gnuplot 将空格以外的内容设置为数据文件的分隔符。
通过运行以下命令确保将哪个字符设置为分隔符。
gnuplot> show datafile separator
并确保您没有在“~/.gnuplot”(在类 UNIX 系统上)中设置 set datafile separator
。
加法:发生了什么
因为分隔符设置为逗号,所以只会读取每行数据中的第一个数字。这相当于下面的数据。
0
0
0
1
1
1
2
2
2
3
3
3
根据块数和内部行数,此数据被视为等效于 4x3 矩阵数据,给定数字被解释为 z 轴上的值。
0 0 0
1 1 1
2 2 2
3 3 3
使用 splot 绘制此数据会再现问题中的图形。
$data <<EOD
0 0 0
1 1 1
2 2 2
3 3 3
EOD
set xlabel "x"
set ylabel "y"
set zlabel "z"
splot $data matrix