X axe on Gnuplot 4.6

旧城冷巷雨未停 提交于 2021-02-11 16:57:08

问题


I've this data :

2020-04;26.94
2020-05;26.92
2020-06;26.89
2020-07;27.01
2020-08;26.73
2020-09;26.72

I use this gnuplot script ( I'm bound to use the 4.6 version of Gnuplot ) :

reset

FILE = "LINEARFIT.txt"
set datafile separator ";"
set xdata time
set timefmt "%Y-%d"
set format x "%Y\n%d"

plot FILE u (StartDate=timecolumn(1)):0 index 0 every ::0:0:0

EndDate = strptime("%Y-%d","2020-20")
f(x) = a*(x-StartDate) + b
FIT_LIMIT = 1e-8
fit f(x) FILE u (timecolumn(1)):2 via a,b

set terminal png truecolor size 900,520 background rgb "#eff1f0"
set output "/xxx/xxx/xxx/xxx.png"
set xrange[StartDate:EndDate]
set grid xtics, ytics
set yrange[0:30]
set format y "%g"
myLabel(n) = sprintf("%g",n)

plot FILE u (timecolumn(1)):2 w lp pt 7 lc rgb "red" notitle, \
'' using 1:2:(myLabel($2)) w labels offset 0,-0.5 notitle, \
      f(x) ti "linear fit with extrapolation"

And the output is :

Can you tell me why, on the x axe, the values are displayed "Two by two" : 2020-04,2020-06,2020-08,2020-10,2020-12,2020-014,2020-16,2020-18,2020-20... While I want 2020-04,2020-05,2020-07,2020-08,2020-09,2020-10,2020-11,2020-12 ....

Could you help me ?

Thanks !


回答1:


X axes on Gnuplot 4.6

Your files are OK with "all dates" : The RHEL 7, CentOS 7 gnuplot-4.6.2, when the x axis is edited to "2020-15" (which is the maximum setting for not showing only "every second date setting")

EndDate = strptime("%Y-%d","2020-15")

The result / the gnuplot behaviour is exactly the same with e.g. gnuplot-5.2.2 .

Other example, gnuplot x labels "time %m.%y settings" https://www.linuxquestions.org/questions/linux-software-2/%5Bgnuplot%5D-ugly-labels-4175670549/#post6096000



来源:https://stackoverflow.com/questions/61340972/x-axe-on-gnuplot-4-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!