如何使 gnuplot 不绘制多行?

How to make gnuplot to NOT plot multiple lines?

我正在绘制一些数据,并且在绘图中出现多条线。应该有一条线,所以我想 gnuplot 正在尝试拟合数据并以一种奇怪的方式连接点或其他东西。我怎样才能让 gnuplot 绘制一条而不是多条线?这是我的脚本:

set term png font 'Liberation Sans,10' size 800,200
set output "data/values.png"
set style line 1 lt 1 lw 1 lc rgb "purple" pt -1
set xlabel "Time" font 'Liberation Sans,10'
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
set xtics font 'Liberation Sans,10'
set ytics font 'Liberation Sans,10'
set autoscale y
plot "data.txt" using 1:5 ls 1 smooth bezier with lines 

您可以使用 sort 对数据进行排序。考虑以下我生成的与您的时间格式一致的数据文件:

2000-12-21 12:32:05 1
2001-11-21 12:32:05 2
2000-12-20 12:32:05 3
2000-12-20 12:32:04 4

键入 sort data.txt 将产生正确的顺序:

2000-12-20 12:32:04 4
2000-12-20 12:32:05 3
2000-12-21 12:32:05 1
2001-11-21 12:32:05 2

您可以使用特殊的输入名称在 gnuplot 中调用它 plot "< sort data.txt" ...:

set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
plot "data.txt" using 1:3 w l

set xdata time
set timefmt "%Y-%m-%d %H:%M:%S"
plot "< sort data.txt" using 1:3 w l

如果您需要针对您的数据格式进行更强大的排序,您可以查阅 sort 文档。