2017-10-14 85 views
-2

我的代码返回1000 snapshot_XXXX.dat文件(XXXX = 0001,0002,...)。它们是两列数据文件,用于拍摄我在特定时间运行的系统的照片。我想按照它们创建的顺序将它们混合在一起来构建2D图(或热图),以显示随时间推移的数量的演变。来自几个输入数据文件的2D图

我该如何使用gnuplot来做到这一点?

+1

显示您的当前代码 – RomanPerekhrest

回答

0

假设要时间轴从底部到顶部,可以尝试以下方法:

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测试)中:

evolution with time from bottom to top

您可以更改订单如果你想从顶部到底部的情节的情节。如果你想从左到右,也许this可以帮助(未测试)。

+0

谢谢,这对我来说是一个很好的起点。 (':(n + 1.5-i):')plot命令中的第二列是什么意思?而且,我可以使用更多颜色的调色板吗?我通常用8种颜色代替2. – ManyBertin

+0

'1:(n + 1.5-i):2'表示'x:y:color',也就是说,y值(时间)是从快照数('n'是快照的总数,'i'是当前绘制的快照的编号,相应的行将出现在'y = n + 1.5-i'处)。有关配置调色板的颜色,请参阅“帮助调色板”或搜索www中的一些示例。 – maij

+0

太棒了。非常感谢 – ManyBertin

相关问题