I am currently measuring irradiance data at specific times for at least two days. The data I have is as follows:
12-03-2025 9:00 600
12-03-2025 9:01 601
12-03-2025 9:02 602
12-03-2025 9:02 603
...
12-03-2025 15:50 500
13-03-2025 9:00 600
13-03-2025 9:01 601
13-03-2025 9:02 602
13-03-2025 9:02 603
...
13-03-2025 15:50 500
I finish data acquisition at 3:51 PM on the first day and resume it the following day. 9:00 AM. When I create the graph, I get a space like the following:
I'd like to remove this space and find a way to make it so that after 3:50 PM on the first day, it coincides with 9:00 AM on the second day. It's worth noting that there is no data after 3:50 PM on the first day, but until the next day at 9:00 AM. I've attached the code used so far.
set size 1.1,1
set yrange [0:1200]
set xlabel "$t (h)$"
set ylabel "G ($W/m^{2}$)"
set xdata time
set timefmt "%d-%m-%Y %H:%M"
set xrange ["12-03-2025 09:00":"13-03-2025 17:00"]
set format x "%H:%M"
set xtics "12-03-2025 09:00",14400,"13-03-2025 17:00"
set terminal epslatex
set output "Prueba.tex"
plot "Datos.dat" using 1:($3) lw 6.5 lc "blue" title "$G_{IP}$" w l
Your question reminds me to an earlier question where weekends should be removed.
Check the following suggestion where I assumed that the daytimes where you have some data (here: t1=09:00
and t2=16:00
) are identical for all days.
The idea is to stretch this time via a function ts()
to span a full day. With this, there could be missing days. But maybe you want them also being removed?
With this irregular time axis, you have to set the xtics manually. Hence, you define a number M
in order to plot only every M
th tic. Some extra code ensures that you start every new day with a label.
The following script creates some random test data for illustration. If you plot this data via
plot $Data u (timecolumn(1,fmt)):3 w l lc "red"
You will get this (in this example, there is no data on 23.03.):
Now, let's remove the gaps, except missing days. However, these can also be removed with some changes in the script.
Script:
### remove time data gaps
reset session
fmt = "%d-%m-%Y %H:%M"
t1 = 9*3600 # starting daytime in secs
t2 = 16*3600 # end daytime in secs
# create some random test data
set table $Data
N = 61
set samples N
tmp = rand(111)
t0 = int(time(0)/86400) * 86400 # today 00:00
t(col) = strftime(fmt,t0+column(col)/(N-1)*(t2-t1)+t1+i*86400)
y(col) = sin(pi*column(col)/(N-1))*(i==2?500:1000)+rand(0)*(i==2?200:50)
plot for [i=1:5] '+' u (t(0)):(y(0)):0 w table if i!=3
unset table
set format x "%d.%m.\n%H:%M" timedate
set key noautotitle
set grid x,y
ts(colD,colH) = timecolumn(colD,"%d-%m-%Y") + (timecolumn(colH,"%H:%M")-t1)/(t2-t1)*86400
M = 30 # plot only every Mth tic
plot $Data u (ts(1,2)):3 w l lc "blue", \
d1=NaN '' u (d0=d1, d1=timecolumn(1,"%d-%m-%Y"), \
d1!=d0 ? c=0 : c=c+1, c%M==0?ts(1,2) : NaN):(NaN): \
xtic(strftime("%d.%m.\n%H:%M",timecolumn(1,fmt)))
### end of script
Result: