我有一个数据集,我想从它生成一组地块,而且我很难让gnuplot来完成它。
我有一个包含以下列的数据集:
YYYY-MM-DDTHH:mm:ss.sssZ)给定的时间戳通常只有一个样本。数据集中大约有7000行。一些示例行如下所示:
time | client | server | stat A1 | stat A2 | stat B1 | stat B2
--------------------+----------+----------+---------+---------+---------+--------
2015-04-01T03:47:12 | client-x | server-1 | 12.2 | 20.0 | 2.3 | 7.0
2015-04-01T03:49:09 | client-y | server-6 | 15.0 | 25.2 | 10.0 | 15.2我想要生成四个地块,作为线图,每个相关的统计数据和客户组合一个。
此时,完全不知所措,不知道如何用gnuplot来处理这件事。我对生成绘图的其他选项持开放态度,但当我获得新的/更新的数据集时,它需要是可编写的。
发布于 2015-04-29 07:29:24
为了获得线条图,您必须在gnuplot之外进行数据过滤,例如使用awk。
首先设置时间格式
set xdata time
set timefmt '%Y-%m-%dT%H:%M:%S'然后提取所有可能的客户端名称,除非您已经知道可能的客户端名称:
clients = system("awk '!/^#/ { print $2 }' test.dat | sort | uniq")然后使用multiplot绘制数据
set style data lines
set multiplot layout 2,2
do for [client in clients] {
set title sprintf("client '%s'", client)
plot sprintf('< grep ''\b%s\b'' test.dat', client) using 1:4 title "A1", '' using 1:5 title "A2"
plot sprintf('< grep ''\b%s\b'' test.dat', client) using 1:6 title "B1", '' using 1:7 title "B2"
}
unset multiplot这个问题与How to use one of the column of data as legend in gnuplot?非常相似。
https://stackoverflow.com/questions/29932510
复制相似问题