我正在尝试使用 gnuplot 绘制图表。 我想在 x 轴上使用数据和时间,但它回答了我: 第 0 行:所有点 y 值未定义!
但是当我使用第一列(而不是日期列,它会生成图表)
我的数据文件:
1 2024-03-09_21-00-01 5.700000
2 2024-03-09_22-00-01 5.700000
3 2024-03-09_23-00-01 5.200000
4 2024-03-10_00-00-03 5.100000
5 2024-03-10_01-00-02 4.900000
6 2024-03-10_02-00-00 4.900000
7 2024-03-10_03-00-02 5.100000
8 2024-03-10_04-00-02 5.500000
9 2024-03-10_05-00-03 5.200000
10 2024-03-10_06-00-03 5.900000
我的工作脚本(不使用日期):
#!/bin/bash
gnuplot -persist <<-EOFMarker
set autoscale y
set pointsize 0.1
plot "./hs.txt" using 1:3 with linespoints
EOFMarker
# rest of script, after gnuplot exits
我的代码在 x 轴上使用日期(但回答所有点 y 值未定义!):
#!/bin/bash
gnuplot -persist <<-EOFMarker
set xdata time
set timefmt '"%Y-%m-%d_%H-%M-%S"'
set xrange ['"2024-03-10_00-00-00"':'"2024-03-10_06-00-00"']
set format x '"%Y-%m-%d"'
set autoscale y
set pointsize 0.1
plot "./hs.txt" using 2:3 with linespoints
EOFMarker
# rest of script, after gnuplot exits
请有人给我一些建议,我做错了什么? 非常感谢大家!
当我尝试解决以前的一些问题时,我找到了使用单引号和双引号的解决方案。但这可能是针对 sam 旧版本的 gnuplot 的。所以我删除了单引号,它现在可以工作了。谢谢大家的回复。
当然 - 工作代码:
#!/bin/bash
gnuplot -persist <<-EOFMarker
set xdata time
set timefmt "%Y-%m-%d_%H-%M-%S"
set xrange ["2024-03-10_00-00-00":"2024-03-10_06-00-00"]
set format x "%Y-%m-%d"
set autoscale y
set pointsize 0.1
plot "./hs.txt" using 2:3 with linespoints
EOFMarker
# rest of script, after gnuplot exits