如何将X轴设置为我的SQL提取临时文件中的日期?

问题描述

经过多次阅读后,我的用例无法正常工作
我暂时还不明白为什么。

我的摘录看起来像这样:

 111 | 98.2 | 2020-07-11
 112 | 99.2 | 2020-07-15
 113 | 98.7 | 2020-07-25
 122 | 99.2 | 2020-07-26
 123 | 99.7 | 2020-07-27
 124 | 97.8 | 2020-07-28

&我的gnuplot代码如下:

gnuplot --persist << EOF || ( exit 3 ) 
set xlabel "temps"
set ylabel "poid"
set terminal GNUTERM background rgb 'grey' size 1024,768
set grid ls 12
set sample 1000
set datafile separator "|"
set yrange [95:100]
set title "SUIVI POID"
set autoscale
plot "poid" with lines smooth bezier,"regime" with lines lt rgb "red","objectif" with lines smooth bezier lt rgb "white"
set terminal png
set output 'poid.png'
replot
pause mouse close
EOF

这样做,我的曲线和体重等等。 但是我有111,112,...,124个值作为X标签

我试图按日期替换:像这样添加几行集合)

set autoscale
set xdata time
set timefmt "%d/%m"
set format x "%b %d"
set xrange ["04/07":"31/12"]
set xtics "04/07",172800,"31/12"
plot "poid" with lines smooth bezier,"objectif" with lines smooth bezier lt rgb "white"
set terminal png

并收到该错误

gnuplot> plot "poid" with lines smooth bezier,"objectif" with lines smooth bezier lt rgb "white"
                                              ^
         line 0: Need full using spec for x time data

围绕该问题,我尝试了很多事情,但失败了。我阅读了许多论坛解决方案,但似乎没人与我的问题匹配(并且我也误解了一些解决方案)

我希望日期作为X标签

解决方法

您很亲近,主要问题是您没有正确声明日期格式,push @BIG,[ [ 'hrdl:raw_:in:__:' ],[ '\.(((tex)|(txt))|((TEX)|(TXT)))' ],]; 应该代表数据中日期的格式,您可以使用相同的方式设置timefmt格式,然后可以使用xrange进行绘制,以告诉gnuplot将第3列用于x坐标,将第2列用于y坐标。

对脚本进行此调整

using 3:2

我从您发布的样本数据摘录中获得了该图。 plot

PD。 set xlabel "temps" set ylabel "poid" set object rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb 'grey' fillstyle solid noborder set grid ls 12 set sample 1000 set datafile separator "|" set yrange [95:100] set title "SUIVI POID" set autoscale set autoscale set xdata time set timefmt "%Y-%m-%d" set format x "%b %d" set xrange ['2020-07-11':'2020-07-28'] plot "test.txt" u 3:2 with lines smooth bezier 终端没有background属性,因此我在所有内容后面都使用了矩形。