GNUPLOT日期错误行为

huangapple go评论72阅读模式
英文:

GNUPLOT incorrect date behavior

问题

GNU绘图在处理这些数据时出现奇怪的行为,但我无法弄清楚原因。

这是我的数据示例:

-2.696764488716512156e-02 2023-05-25
-2.514640039066843094e-02 2023-05-25
-2.539875589417509363e-02 2023-05-25
-2.443511139767776813e-02 2023-05-25
-2.258826690118204833e-02 2023-05-25
-2.176542240468394215e-02 2023-05-25

现在使用小时时间工作,但我正在尝试使用以下配置绘制天数:

set terminal png size 1074,806
set output 'output.png'
set datafile sep ' '
set xdata time
set timefmt "%Y-%m-d%"
set format x "%m/%d"
set autoscale y
set style data lines
set xlabel 'Days'
plot "gnudataok.dat" using 2:1 with lines lt rgb "blue"

但我无法在X轴上获得正确的日期。

英文:

GNU plot is giving a strange behavior with this data, but I cannot figure our why.

here is my data example :

-2.696764488716512156e-02 2023-05-25
-2.514640039066843094e-02 2023-05-25
-2.539875589417509363e-02 2023-05-25
-2.443511139767776813e-02 2023-05-25
-2.258826690118204833e-02 2023-05-25
-2.176542240468394215e-02 2023-05-25

Now using HOURS time work, but I am trying to plot for DAYS with this configuration :

set terminal png size 1074,806
set output 'output.png'
set datafile sep ' '
set xdata time
set timefmt "%Y-%m-d%"
set format x "%m/%d"
set autoscale y
set style data lines
set xlabel 'Days'
plot "gnudataok.dat"  using 2:1 with lines lt rgb "blue"  

But I cannot get correct dates on the X axis

enter image description here

答案1

得分: 0

在你的脚本中有一个拼写错误 "%Y-%m-d%",而正确的是 "%Y-%m-%d"

注意,如果你的时间精度只是整天,所有这些数据点将会重叠在一起。

以下脚本(其中一些日期已经更改)将给出下面的结果...

脚本:

### 时间数据
reset session

$Data <<EOD
-2.696764488716512156e-02 2023-05-25
-2.514640039066843094e-02 2023-05-25
-2.539875589417509363e-02 2023-05-26
-2.443511139767776813e-02 2023-05-26
-2.258826690118204833e-02 2023-05-27
-2.176542240468394215e-02 2023-05-27
EOD

myTimeFmt = "%Y-%m-%d"
set format x "%m/%d" timedate
set xlabel '天数'

plot $Data u (timecolumn(2,myTimeFmt)):1 w lines lc rgb "blue"
### 脚本结束

结果:

GNUPLOT日期错误行为

英文:

There is a typo in your script "%Y-%m-d%" instead of "%Y-%m-%d"

Note, if your time precision is just whole days, all these datapoints will be plotted on top of each other.

The following script (with some dates changed) will give the result below...

Script:

### time data
reset session

$Data <<EOD
-2.696764488716512156e-02 2023-05-25
-2.514640039066843094e-02 2023-05-25
-2.539875589417509363e-02 2023-05-26
-2.443511139767776813e-02 2023-05-26
-2.258826690118204833e-02 2023-05-27
-2.176542240468394215e-02 2023-05-27
EOD

myTimeFmt = "%Y-%m-%d"
set format x "%m/%d" timedate
set xlabel 'Days'

plot $Data u (timecolumn(2,myTimeFmt)):1 w lines lc rgb "blue"
### end of script

Result:

GNUPLOT日期错误行为

huangapple
  • 本文由 发表于 2023年5月26日 13:47:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76337959.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定