Gnuplot 多个输入数据文件的二维绘图

Gnuplot 多个输入数据文件的二维绘图,gnuplot,Gnuplot,我的代码正在返回1000个快照XXXX.dat文件(XXXX=00010002,…)。它们是两列数据文件,用于拍摄我在特定时间运行的系统的图片。我想按照它们被创建的顺序混合它们,以构建一个2D图(或热图),该图将显示我正在跟踪的数量随时间的演变 如何使用gnuplot实现这一点?假设您希望时间轴从下到上,可以尝试以下操作: n=4 # Number of snapshots set palette defined (0 "white", 1 "red") unset key set styl

我的代码正在返回1000个快照XXXX.dat文件(XXXX=00010002,…)。它们是两列数据文件,用于拍摄我在特定时间运行的系统的图片。我想按照它们被创建的顺序混合它们,以构建一个2D图(或热图),该图将显示我正在跟踪的数量随时间的演变


如何使用gnuplot实现这一点?

假设您希望时间轴从下到上,可以尝试以下操作:

n=4  # Number of snapshots

set palette defined (0 "white", 1 "red")
unset key
set style fill solid

set ylabel "Snapshot/Time"
set yrange [0.5:n+0.5]
set ytics 1

# This functions gives the name of the snapshot file
snapshot(i) = sprintf("snapshot_%04d.dat", i)

# Plot all snapshot files.
# - "with boxes" fakes the heat map
# - "linecolor palette" takes the third column in the "using" 
#   instruction which is the second column in the datafiles
# Plot from top to bottom because each boxplot overlays the previous ones.

plot for [i=1:n] snapshot(n+1-i) using 1:(n+1.5-i):2 with boxes linecolor palette
此示例提供了数据

snapshot_0001.dat  snapshot_0002.dat  snapshot_0003.dat  snapshot_0004.dat
1.0 0.0            1.0 0.0            1.0 0.0            1.0 0.0
1.5 0.0            1.5 0.0            1.5 0.0            1.5 0.0
2.0 0.5            2.0 0.7            2.0 0.7            2.0 0.7
2.5 1.0            2.5 1.5            2.5 1.5            2.5 1.5
3.0 0.5            3.0 0.7            3.0 1.1            3.0 1.5
3.5 0.0            3.5 0.0            3.5 0.7            3.5 1.1
4.0 0.0            4.0 0.0            4.0 0.0            4.0 0.7
4.5 0.0            4.5 0.0            4.5 0.0            4.5 0.0
5.0 0.0            5.0 0.0            5.0 0.0            5.0 0.0
此图像中的结果(使用Gnuplot 5.0测试):


如果要从上到下,可以更改绘图顺序。如果您想从左向右,也许可以提供帮助(未经测试)。

显示您当前的代码谢谢,这对我来说是一个很好的起点。plot命令中(
:(n+1.5-i):
)第二列的含义是什么?此外,我可以使用更多颜色的调色板吗?我通常使用8种颜色而不是2。
1:(n+1.5-I):2
表示
x:y:color
,也就是说,y值(时间)是从快照的数量计算出来的(
n
是快照的总数,
I
是当前绘制快照的数量,相应的行将出现在
y=n+1.5-I
)。有关配置调色板颜色的信息,请参阅
帮助调色板
,或在www上搜索一些示例。