英文:
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
答案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"
### 脚本结束
结果:
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论