我有一个数据集,我想从中生成一组图,但我无法让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来解决这个问题。我对其他用于生成绘图的选项持开放态度,但是当我获得新的/更新的数据集时,它需要是可编写脚本的。
答案 0 :(得分:1)
为了获得线图,您必须在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?非常相似。