Related
Below is the script used to generate the plot. What should I change to fix the spacing of the xtic text? I have macOS Catalina.#theozh
#/Users/CourtneyBrea/Desktop/ORR-Figures/free-energy-diagram
myFileIn(i) = sprintf("step-%d.dat",i)
myFileOut(i) = sprintf("step-%d.svg",i)
set term svg font "{/:Bold}Sans,22"
set border 15 front lt black linewidth 3.000 dashtype solid
set xlabel "Reaction Coordinate"
set xrange [-0.2:5.2]
set xtics nomirror scale 0
set ylabel "Free Energy (eV)"
set yrange[-5:0.1]
set ytics out nomirror
set key noautotitle samplen 2
set errorbars 0
dx = 0.2
do for [i=1:30] {
set output myFileOut(i)
plot myFileIn(i) u 0:2:(dx):xtic(1) w xerr lc "blue" lw 3 ps 0 ti columnheader(2), \
'' u 0:3:(dx) w xerr lc "red" lw 3 ps 0 ti columnheader(3), \
x1=y1=NaN '' u (x0=x1,x1=$0,x0-1+dx):(y0=y1,y1=$2,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "blue" nohead, \
x1=y1=NaN '' u (x0=x1,x1=$0,x0-1+dx):(y0=y1,y1=$3,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "red" nohead
}
set output # close the last file
### end of script
Input file below
"Reaction Coordinate" "0 V" "0.43 V"
O_{2} 0 -3.00
O#^*_{2} -0.10 -3.67
OOH^* -1.00 -3.90
O^* -2.00 -4.00
OH^* -4.00 -4.92
H_{2}O -4.92 -4.92
I suspect the problem is that you have placed the enhanced text notation for bold text in the font name rather than placing it in the text being printed. That probably confuses the program you are using to view the resulting svg file.
The correct way is to set the terminal font as just a name and a size, and then separately add any additional markup to the text strings. Revised commands below, with a screen capture of the svg file as viewed in firefox.
Note that I have applied the bold attribute only to the tic labels, because that is the tricky part. You can apply to other labels or text as you like.
set term svg font "Sans,22"
set output "gap.svg"
makebold(text) = sprintf("{/:Bold %s}", text)
set border 15 front lt black linewidth 3.000 dashtype solid
set xlabel "Reaction Coordinate"
set xrange [-0.2:5.2]
set xtics nomirror scale 0
set ylabel "Free Energy (eV)"
set yrange[-5:0.1]
set ytics out nomirror
set key noautotitle samplen 2
set errorbars 0
dx = 0.2
plot "gap.dat" u 0:2:(dx):xtic(makebold(strcol(1))) w xerr lc "blue" lw 3 ps 0 ti columnheader(2), \
'' u 0:3:(dx) w xerr lc "red" lw 3 ps 0 ti columnheader(3), \
x1=y1=NaN '' u (x0=x1,x1=$0,x0-1+dx):(y0=y1,y1=$2,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "blue" nohead, \
x1=y1=NaN '' u (x0=x1,x1=$0,x0-1+dx):(y0=y1,y1=$3,y0):(1-2*dx):(y1-y0) w vec dt 4 lc "red" nohead
How can I label a datapoint on a specific y value with its corresponding x value? Extra difficulty is the x values should be in hours and not date.
I have this data:
data.csv:
2019-01-04-11:02:24,1.468
2019-01-04-12:40:54,1.212
2019-01-04-15:16:22,1.123
2019-01-04-17:04:43,1.067
2019-01-04-18:51:45,0.994
2019-01-04-19:51:21,0.919
2019-01-04-20:46:40,0.8
I plot it with:
set datafile separator ","
set terminal png size 600,300 enhanced font 'Verdana,10' linewidth 1
set output 'data.png'
set xdata time
MyTimeFormat = "%Y-%m-%d-%H:%M:%S"
set timefmt MyTimeFormat
set format x "%tH"
set xlabel "hours"
set ylabel "Volt"
set grid ytics xtics mxtics
StartTime = strptime(MyTimeFormat,"2019-01-04-11:01:31")
EndTime = strptime(MyTimeFormat,"2019-01-04-20:47:17")
plot 'data.csv' u (timecolumn(1)-StartTime):2 w lines lw 1 notitle,\
'' u (timecolumn(1)-StartTime):2:1 w labels notitle
That gives this plot:
Lets assume I am interested in displaying a single y value 0.89. How can I label the intersection on the plot with the corresponding x value in hours, like in this plot:
I know the problem is that point does not exist in my data but is this possible anyway? If not, how to do it with an existing y value near the desired value for example this value:
2019-01-04-19:51:21,0.919
Check the following. The ternary operator helps you here.
The label of the first value which is below a certain threshold is plotted as label.
Of course, it would be nicer interpolate the value at the threshold, which also can be done but requires some more coding.
### threshold value as label
reset session
$Data <<EOD
2019-01-04-11:02:24,1.468
2019-01-04-12:40:54,1.212
2019-01-04-15:16:22,1.123
2019-01-04-17:04:43,1.067
2019-01-04-18:51:45,0.994
2019-01-04-19:51:21,0.919
2019-01-04-20:46:40,0.8
EOD
set datafile separator ","
#set terminal png size 600,300 enhanced font 'Verdana,10' linewidth 1
#set output 'data.png'
set xdata time
MyTimeFormat = "%Y-%m-%d-%H:%M:%S"
set timefmt MyTimeFormat
set format x "%tH"
set xlabel "hours"
set ylabel "Volt"
set grid ytics xtics mxtics
StartTime = strptime(MyTimeFormat,"2019-01-04-11:01:31")
EndTime = strptime(MyTimeFormat,"2019-01-04-20:47:17")
set multiplot layout 2,1
OffsetY = 0.1
plot $Data u (timecolumn(1)-StartTime):2 w lp lt 7 lc rgb "red" notitle,\
'' u (timecolumn(1)-StartTime):($2+OffsetY):(sprintf("%.2f",(timecolumn(1)-StartTime)/3600)) w labels notitle
Threshold = 1.1
a = NaN
Flag = 1
plot $Data u (timecolumn(1)-StartTime):2 w lp lt 7 lc rgb "blue" notitle,\
'' u (a = timecolumn(1)-StartTime):\
($2+OffsetY):\
(($2<Threshold) & (Flag==1) ? (Flag=0, sprintf("%.2f|%g",a/3600,Threshold)) : "") w labels notitle
unset multiplot
### end of code
Which results in:
Addition:
Another improved bit more complex solution finds the point of interest (POI) in a first pass, interpolates and finally adds lines and labels.
### threshold value as label
reset session
$Data <<EOD
2019-01-04-11:02:24,1.468
2019-01-04-12:40:54,1.212
2019-01-04-15:16:22,1.123
2019-01-04-17:04:43,1.067
2019-01-04-18:51:45,0.994
2019-01-04-19:51:21,0.919
2019-01-04-20:46:40,0.8
EOD
set datafile separator ","
# set terminal png size 600,300 enhanced font 'Verdana,10' linewidth 1
# set output 'data.png'
set xdata time
MyTimeFormat = "%Y-%m-%d-%H:%M:%S"
set timefmt MyTimeFormat
set format x "%tH:%tM"
set xlabel "hours"
set ylabel "Volt"
set grid ytics xtics mxtics
# settings
Threshold = 0.89
LabelOffsetY = 0.1
Flag = 0
LastX = LastY = TempX = TempY = POIx = NaN
# formula for interpolation and finding the threshold x value
Interpolate(x0,y0,x1,y1,xi) = y0 + (y1-y0)/(x1-x0)*(xi-x0)
ThresholdX(X,Y) = ((LastY>=Threshold) & (Y<Threshold) & (Flag==0)) ? \
(Flag=1, POIx = Interpolate(LastY,LastX,Y,X,Threshold)) : NaN
set table $Dummy
plot $Data u ($0 == 0 ? (StartTime = timecolumn(1), 0) : LastX = TempX, TempX = timecolumn(1)-StartTime, LastY = TempY, TempY = $2, ThresholdX(TempX,TempY)):\
(TempY) w table
unset table
# lines and label
set arrow 1 from graph 0, first Threshold to POIx,Threshold lc rgb "red" nohead
set arrow 2 from POIx,graph 0 to POIx,Threshold lc rgb "red" nohead
set arrow 3 from POIx,Threshold+LabelOffsetY*0.8 to POIx,Threshold lc rgb "black" lw 1.5
set style textbox opaque
set label 1 at POIx,Threshold+LabelOffsetY sprintf("%.2f/%.2f", POIx/3600, Threshold) boxed front
# plotting data
plot $Data u (timecolumn(1)-StartTime):2 w lp lt 7 lc rgb "blue" notitle
### end of code
I'm doing a multiplot on gnuplot 5.0 and I set my own labels for the y axis, but it seems that some of these labels are plotted more than once, since they have a bold outlook.
Here is what it looks like:
Here is my code:
set multiplot layout 3,2 rowsfirst title 'Time stuff'
TOPGRAPH = "set tmargin at screen 0.80;set bmargin at screen 0.60;set ytics(0,14,18,22);set yrange[12:22];unset ylabel"
MIDDLEGRAPH = "set tmargin at screen 0.60;set bmargin at screen 0.40;set ytics(0,2,5,8);set yrange[0:10];unset ylabel"
BOTTOMGRAPH = "set tmargin at screen 0.40;set bmargin at screen 0.20;set ytics(0,6,7);set yrange[5:8];unset ylabel"
LRMARGIN = "set lmargin at screen 0.15;set rmargin at screen 0.45"
NOXLABEL = "unset xlabel"
XTICS = "set xtics 0,2500,10000; set format ''"
#TOPGRAPH;#LRMARGIN;#NOXLABEL;#XTICS
set label 1 'X length' at screen 0.10, 0.65 rotate left
plot 'ite_x' u 1:3:4 w filledcu lc 'grey' notitle, 'ite_x' u 1:2 w lines lc 'red' notitle
#MIDDLEGRAPH;#LRMARGIN;#NOXLABEL;#XTICS
set label 2 'Y length' at screen 0.10,0.45 rotate left
plot 'ite_y' u 1:3:4 w filledcu lc 'grey' notitle, 'ite_y' u 1:2 w lines lc 'red' notitle
#BOTTOMGRAPH;#LRMARGIN
set arrow from 0,5 to 0,8 nohead front
set label 3 'Z length' at screen 0.10,0.25 rotate left
unset format x
set xtics 0,2500,10000
set xlabel 'Time when bead placed'
plot 'ite_z' u 1:3:4 w filledcu lc 'grey' notitle, 'ite_z' u 1:2 w lines lc 'red' notitle
I am experiencing an erratic behaviour on a heavy lined gnuplot script.
The script intends to plot borderlines. Filledcurve and line styles are used. Also a mono-parametric family of curves are displayed via
plot for [i=1:4] f(x,i) title sprintf("f(x,i) i=%d",i) w l dt 2
I tweeted an example here https://pbs.twimg.com/media/DHbeEgXXkAAV6aS.jpg:large
After this plot I continued introducing Argentina. After a new lines of codes the dashed lines in blue started to behave erratically. Two of them simply vanished.
I started debugging the code and ultimately make use of the set table utility outputing the whole plot into a single file.
I found the for-loop was behaving erraticly. The title line showed that the loop variable i was correctly running from start to end values. However the function f(x,i) was not properly fed with the correct value of i.
On the first iteration the value the loop worked fine and the script plotted f(x,1). On the second iteration the function was correctly fed and displayed f(x,2). But hereafter the function was always fed with i=2 despite title string correctly showed the change in i
The resulting plot was
I would really appreciate a hint helping me to find the bug.
I will now add a few lines of code. The plot command
plot for [i=1:words(europa_cet)] countries u ($1+($2<36?1:0)*15):(mercator($2)) index (word(europa_cet,i)+0) w filledcurve lc rgb colorFondoCET,\
for [i=1:words(paises_wet)] countries u ($1+15+dst*word(dst_wet,i)*15):(mercator($2)) index (word(paises_wet,i)+0) w filledcurve lc rgb colorFondoWET,\
for [i=1:words(southAm)] countries u ($1+(4+dst*word(dstSouthAm,i))*15):(mercator(abs($2))) index int(word(southAm,i)) w filledcurve lc rgb colorFondoGET,\
"magallanes.dat" u (new!=2?$1+dst*15:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
"no_magallanes.dat" u (new!=2?$1:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
for [k=1:5:1] mercator(orto(x,real(b1)+real(k)*real(15.0))) tit sprintf("orto a %02d signo %d",k,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+1*15)) tit sprintf("no loop orto a %02d signo %d",1,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+2*15)) tit sprintf("no loop orto a %02d signo %d",2,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+3*15)) tit sprintf("no loop orto a %02d signo %d",3,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+4*15)) tit sprintf("no loop orto a %02d signo %d",4,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+5*15)) tit sprintf("no loop orto a %02d signo %d",5,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+0*15)) tit sprintf("no loop orto a %02d signo %d",0,Signo) w l lc rgb 'blue' dt 2 lw 3,\
The for-loop (line #6) do not work. Line-by-line calls (lines 7-12) do work.
And the output obtained from set table, first lines of each iteration
# Curve 43 of 104, 100 points FIRST iteration
# Curve title: "orto a 01 signo 1"
# x y type
-22.5 0.874361° i
-21.9697 0.887919° i
-21.4394 0.901287° i
-20.9091 0.914467° i
# Curve 44 of 104, 100 points SECOND iter
# Curve title: "orto a 02 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 45 of 104, 100 points THIRD iter (REPEATS 2nd)
# Curve title: "orto a 03 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 46 of 104, 100 points FOURTH iter (repeats 2nd)
# Curve title: "orto a 04 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
# Curve 47 of 104, 100 points FIFTH iter (repeats 2nd)
# Curve title: "orto a 05 signo 1"
# x y type
-22.5 0.407722° i
-21.9697 0.426936° i
-21.4394 0.445968° i
-20.9091 0.464814° i
Now I have isolated the problem.
I am pasting again the plot (multi)line. The plot line is run two times one for the left (sunrise) subplot, the second for the right (sunset) subplot in a multiplot environment. They differ in the definition of the function orto and the value for b1.
plot "usa.dat" u (usaBool?($1+6*15):1/0):(mercator($2)) w filledcurve lc rgb colorFondoFET,\
for [i=1:words(europa_cet)] countries u ($1+($2<36?1:0)*15):(mercator($2)) index (word(europa_cet,i)+0) w filledcurve lc rgb colorFondoCET,\
for [i=1:words(paises_wet)] countries u ($1+15+dst*word(dst_wet,i)*15):(mercator($2)) index (word(paises_wet,i)+0) w filledcurve lc rgb colorFondoWET,\
for [i=1:words(southAm)] countries u ($1+(4+dst*word(dstSouthAm,i))*15):(mercator(abs($2))) index int(word(southAm,i)) w filledcurve lc rgb colorFondoGET,\
"magallanes.dat" u (new!=2?$1+dst*15:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
"no_magallanes.dat" u (new!=2?$1:1/0):(mercator($2)) w filledcurve lc rgb colorFondoEET,\
mercator(orto(x,b1+1*15)) tit sprintf("no loop orto a %02d signo %d",1,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+2*15)) tit sprintf("no loop orto a %02d signo %d",2,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+3*15)) tit sprintf("no loop orto a %02d signo %d",3,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+4*15)) tit sprintf("no loop orto a %02d signo %d",4,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+5*15)) tit sprintf("no loop orto a %02d signo %d",5,Signo) w l lc rgb 'blue' dt 2 lw 3,\
mercator(orto(x,b1+0*15)) tit sprintf("no loop orto a %02d signo %d",0,Signo) w l lc rgb 'blue' dt 2 lw 3,\
for [i=1:words(europa_cet)] countries u ($1+($2<36?1:0)*15):(mercator($2)) index (word(europa_cet,i)+0) w l lt 1 lc rgb colorLinea,\
for [i=1:words(paises_wet)] countries u ($1+15*(1+dst*word(dst_wet,i))):(mercator($2)) index (word(paises_wet,i)+0) w l lt 1 lc rgb colorLinea,\
for [i=1:words(southAm)] countries u ($1+(4+dst*word(dstSouthAm,i))*15):(mercator(abs($2))) index int(word(southAm,i)) w l lt 1 lc rgb colorLinea,\
"magallanes.dat" u (new!=2?$1+dst*15:1/0):(mercator($2)) w l lt 1 lc rgb colorLinea,\
"no_magallanes.dat" u (new!=2?$1:1/0):(mercator($2)) w l lt 1 lc rgb colorLinea,\
"usa.dat" u (usaBool?($1+6*15):1/0):(mercator($2)) w l lt 1 lc rgb 'gray50',\
for [i=0:2] "ciudadesChile.dat" u ($2-($6-1+((new==0&i==2)?-1:((new==2&i==1)?1:0))-dst*word(dstSouthAm,i+1))*15):(mercator(abs($1))) index i w p pt 7 lc 1 ps 1.5,\
"ciudadesUsa.dat" u (usaBool?($2+6*15):1/0):(mercator(abs($1))) w p pt 7 lc rgb 'blue' ps 1.5,\
for [k=1:5:1] mercator(orto(x,real(b1)+real(k)*real(15.0))) tit sprintf("orto a %02d signo %d",k,Signo) w l lc rgb 'green' dt 2 lw 10,\
for [i=0:2] "ciudadesChile.dat" u ($2-($6-1+((new==0&i==2)?-1:((new==2&i==1)?1:0))-dst*real(word(dstSouthAm,i+1)+0))*15-$4*.5):(mercator(abs($1+$5*1.1))):(stringcolumn($3)) index i w labels font "Arial-Bold,10" tc rgb word(corporativa,1),\
"ciudadesUsa.dat" u (usaBool?($2+6*15-$4*.5):1/0):(mercator(abs($1+$5*1.1))):3 w labels font "Arial-Bold,10" tc rgb 'blue',\
for [i=1:words(Coastlines)] coastline u 1:(mercator($2)) index (word(Coastlines,i)+0) w l lt 1 lc rgb 'gray50',\
Problem is with the 3rd line from bottom, the one starting with for [i=0:2].
If this line is removed; the loop for [k=1:5:1] operates ok.
If for [k=1:5:1] is placed after 3rd line from bottom, the script operates ok.
If for [k=1:5:1] is placed before 3rd line from bottom, the loop does not operate fine.
The for [i=0:2] prints names of Chilean and Argentinean cities. Column $1 is latitude, $2 is longitude. They are displaced from center throu $4 and $5. The variable i through index controls the country: Argentina=0 Chile=1 RegionMagallanes (Chile)=2. The variable new controls time zone in Chile new=0 is prior to 2015; new=1 is current status, new=2 refers to 2015. Column $6refers to a reference time zone (-3 Argentina and Magallanes, -4 Chile).
The script also controls winter (dst=0) or summer (dst=1) condition.
I have tried and remove pieces (monomials) of the for [i=0:2] line one by one. No success. Even I edited the ciudadesChile.dat file and changed a tab separating $1 and $2 to a space. No success.
I have the next problem. I had an datafile like;
1412481600,304,0,0,0,304,0
1412485200,385,0,0,0,383,0
1412488800,332,0,0,0,331,0
1412492400,359,0,0,0,355,0
I have changed the format to;
08-11-2014-17:00,390,0,27,417
08-11-2014-18:00,474,0,0,474
08-11-2014-19:00,467,0,0,467
08-11-2014-20:00,687,0,0,687
I changed either the gnuplotscript.
First was;
set timefmt x "%s"
To now in;
set timefmt x "%d-%m-%Y-%H:%M"
In the new situation gnuplot gives me 2 columns they are overwrite
with other columns.
What am I doing wrong or I forget ?
Here the working en wrong example;
And this is the complete code;
file = 'uur.txt'
set output "dag.png"
set datafile separator ","
set linestyle 1 lt 1 lc rgb "black"
set bmargin 5 # witruimte onder grafiek
set boxwidth 600 absolute
set style boxplot
set border back
dy=500 # zie y waarde terminal
# Hier worden de maximale en minimale y-waarden van gnuplot bepaald.
set terminal unknown
plot "<tail -24 ".file."" using :(-$5) w p, '' u :4 w p
ymax= GPVAL_Y_MAX
ymin= GPVAL_Y_MIN
ptmax=ymax*dy/(ymax-ymin)
ptmin=ymin*dy/(ymax-ymin)
replot
set terminal pngcairo truecolor enhanced size 1200, 500 font "Courier Bold,10" background rgb "#CFCFFF"
stats "<tail -24 ".file."" using 2:3 nooutput
afnt = STATS_sum_x
gelt = STATS_sum_y
afn = afnt/24
gel = gelt/24
stats "< tail -24 ".file."" using 4:5 nooutput
zon = STATS_max_x
zont = STATS_sum_x
geb = STATS_max_y
gebt = STATS_sum_y
zonavg = STATS_sum_x/24
gebavg = STATS_sum_y/24
stats "<tail -1 ".file."" using (strptime('%d-%m-%y %H:%M', stringcolumn(1))) nooutput
tijd = strftime('%H:%M', STATS_max)
set palette defined (-(geb) "#ee0000", 0 "#0000cc", 0 "#00aa00", (zon) "#ff0000")
unset colorbox
set title 'Alle energie-stromen van de laatste 24 uur.' font "Courier-Bold,12"
set xdata time
set timefmt '%d-%m-%y-%H:%M'
set xtics format "%H:%M" # dit is de opmaak zoals je hem gaat zien
set xtics 3600
set mxtics 0 # zet sub(minor)streepjes op de x-as
set grid ls 1 lw 1 lc rgb "#a0a0a0"
set autoscale xfix
set ytics font "Helvetica,8"
set mytics 2
set y2tics axis out 0
set ylabel "V e r m o g e n in Watt" offset 2,1
set object rect from screen 0.05, screen 0.04 to screen 0.08, screen 0.06 fc rgb '#00B900' front
set object rect from sc 0.05, sc 0.01 to sc 0.08, sc 0.03 fc rgb 'blue' front
set object rect from sc 0.25, sc 0.04 to sc 0.28, sc 0.06 fc rgb 'green'
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "red" fs solid 1.0 front
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "#5555ff" fs solid 1.0 front
# graph x, y
set label font "Courier Bold, 10" # grootte font tbv labels in het grafiek
set label 1 sprintf("Energiestromen gemiddeld per uur.") at screen 0.05,0.08 tc rgb "black" front
set label 2 sprintf("Zon = %4.0f W/h",zonavg) at screen 0.085,0.05 front
set label 3 sprintf("Gebruikt = %4.0f W/h",gebavg) at screen 0.085,0.025 front
set label 4 sprintf("Geleverd = %4.0f W/h",gel) at screen 0.285,0.05 front
set label 5 sprintf("Afgenomen = %4.0f W/h",afn) at screen 0.285,0.025 front
set label 6 sprintf("Energiestromen van de afgelopen 24 uur.") at screen 0.5,0.08 front
set label 7 sprintf("Gebruikt (%dW) = zon (%dW) - geleverd (%dW) + afgenomen (%dW)", gebt, zont, gelt, afnt) at screen 0.5,0.05 tc rgb "black" front
set label 11 sprintf("Logtijd: ") at screen 0.05,0.92 font "Courier-Bold,8" front
set label 12 sprintf(tijd) at screen 0.091,0.92 font "Courier-Bold,8" front
set style fill solid noborder# was transparent solid 0.5 border 0.5
n = 51
# n is het aantal kolommen wat wordt opgebouwd teneinde een gradient te krijgen. Hoe hoger "n" des te vloeiender de gradient
# De 1e serie is zon, de 2e serie is geleverd, de 3e serie is gebruik en de 4e serie is afgenomen.
# Het getal 12 is het aantal punten van één karakter Courier-Bold 10 hetgeen hier is gebruikt voor de labels.
plot for [i=n:0:-1] "<tail -24 ".file."" u ($1-600):(($4/n)*i):(($4/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u ($1-600):4:( $4>0 && ($4/ymax*ptmax)> (12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels right rotate font ",10" tc rgb "white" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1-600):4:( $4>0 && ($4/ymax*ptmax)<=(12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1-600):4 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):3 w boxes lt 1 lc rgb "green" fillstyle solid notitle,\
"<tail -24 ".file."" u ($1+600):3 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):3:( $3>0 && ($3/ymax*ptmax)> (12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels right rotate font ",10" tc rgb "blue" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1+600):3:( $3>0 && ($3/ymax*ptmax)<=(12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
for [i=n:0:-1] "<tail -24 ".file."" u ($1-600):((-($5)/n)*i):((-($5)/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u ($1-600):(-$5):( $5>0 && ($5/ymax*ptmax)> (12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1-600):(-$5):( $5>0 && ($5/ymax*ptmax)<=(12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u ($1-600):(-$5) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):(-$2) w boxes lc rgb "#5555ff" fillstyle solid notitle,\
"<tail -24 ".file."" u ($1+600):(-$2) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u ($1+600):(-$2):( $2>0 && ($2/ymax*ptmax)> (12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u ($1+600):(-$2):( $2>0 && ($2/ymax*ptmax)<=(12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle
The complete datafile can you find here: http://ccvd.eu/downloads/uur.txt
There are two problems: First you must use the correct time format %d-%m-%Y-%H:%M in all cases (in the script you posted, you have a small y, and in the stats command you are missing a dash).
And, second, you must use timecolumn(1) instead of $1 in the using statement in order to have the date parsed correctly. When you had a timestamp, it worked fine since it was only a number, but parsing of the string failed. So your complete script should be
file = 'uur.txt'
set output "dag.png"
set datafile separator ","
set linestyle 1 lt 1 lc rgb "black"
set bmargin 5 # witruimte onder grafiek
set boxwidth 600 absolute
set style boxplot
set border back
dy=500 # zie y waarde terminal
# Hier worden de maximale en minimale y-waarden van gnuplot bepaald.
set terminal unknown
plot "<tail -24 ".file."" using :(-$5) w p, '' u :4 w p
ymax= GPVAL_Y_MAX
ymin= GPVAL_Y_MIN
ptmax=ymax*dy/(ymax-ymin)
ptmin=ymin*dy/(ymax-ymin)
replot
set terminal pngcairo truecolor enhanced size 1200, 500 font "Courier Bold,10" background rgb "#CFCFFF"
stats "<tail -24 ".file."" using 2:3 nooutput
afnt = STATS_sum_x
gelt = STATS_sum_y
afn = afnt/24
gel = gelt/24
stats "< tail -24 ".file."" using 4:5 nooutput
zon = STATS_max_x
zont = STATS_sum_x
geb = STATS_max_y
gebt = STATS_sum_y
zonavg = STATS_sum_x/24
gebavg = STATS_sum_y/24
stats "<tail -1 ".file."" using (strptime('%d-%m-%Y-%H:%M', stringcolumn(1))) nooutput
tijd = strftime('%H:%M', STATS_max)
set palette defined (-(geb) "#ee0000", 0 "#0000cc", 0 "#00aa00", (zon) "#ff0000")
unset colorbox
set title 'Alle energie-stromen van de laatste 24 uur.' font "Courier-Bold,12"
set xdata time
set timefmt '%d-%m-%Y-%H:%M'
set xtics format "%H:%M" # dit is de opmaak zoals je hem gaat zien
set xtics 3600
set mxtics 0 # zet sub(minor)streepjes op de x-as
set grid ls 1 lw 1 lc rgb "#a0a0a0"
set autoscale xfix
set ytics font "Helvetica,8"
set mytics 2
set y2tics axis out 0
set ylabel "V e r m o g e n in Watt" offset 2,1
set object rect from screen 0.05, screen 0.04 to screen 0.08, screen 0.06 fc rgb '#00B900' front
set object rect from sc 0.05, sc 0.01 to sc 0.08, sc 0.03 fc rgb 'blue' front
set object rect from sc 0.25, sc 0.04 to sc 0.28, sc 0.06 fc rgb 'green'
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "red" fs solid 1.0 front
set object 10 rect from sc 0.25, sc 0.01 to sc 0.28, sc 0.03 fc rgb "#5555ff" fs solid 1.0 front
# graph x, y
set label font "Courier Bold, 10" # grootte font tbv labels in het grafiek
set label 1 sprintf("Energiestromen gemiddeld per uur.") at screen 0.05,0.08 tc rgb "black" front
set label 2 sprintf("Zon = %4.0f W/h",zonavg) at screen 0.085,0.05 front
set label 3 sprintf("Gebruikt = %4.0f W/h",gebavg) at screen 0.085,0.025 front
set label 4 sprintf("Geleverd = %4.0f W/h",gel) at screen 0.285,0.05 front
set label 5 sprintf("Afgenomen = %4.0f W/h",afn) at screen 0.285,0.025 front
set label 6 sprintf("Energiestromen van de afgelopen 24 uur.") at screen 0.5,0.08 front
set label 7 sprintf("Gebruikt (%dW) = zon (%dW) - geleverd (%dW) + afgenomen (%dW)", gebt, zont, gelt, afnt) at screen 0.5,0.05 tc rgb "black" front
set label 11 sprintf("Logtijd: ") at screen 0.05,0.92 font "Courier-Bold,8" front
set label 12 sprintf(tijd) at screen 0.091,0.92 font "Courier-Bold,8" front
set style fill solid noborder# was transparent solid 0.5 border 0.5
n = 51
# n is het aantal kolommen wat wordt opgebouwd teneinde een gradient te krijgen. Hoe hoger "n" des te vloeiender de gradient
# De 1e serie is zon, de 2e serie is geleverd, de 3e serie is gebruik en de 4e serie is afgenomen.
# Het getal 12 is het aantal punten van één karakter Courier-Bold 10 hetgeen hier is gebruikt voor de labels.
plot for [i=n:0:-1] "<tail -24 ".file."" u (timecolumn(1)-600):(($4/n)*i):(($4/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4:( $4>0 && ($4/ymax*ptmax)> (12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels right rotate font ",10" tc rgb "white" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4:( $4>0 && ($4/ymax*ptmax)<=(12 * strlen(sprintf("%d", $4))) ? $4 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):4 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3 w boxes lt 1 lc rgb "green" fillstyle solid notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3 w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3:( $3>0 && ($3/ymax*ptmax)> (12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels right rotate font ",10" tc rgb "blue" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):3:( $3>0 && ($3/ymax*ptmax)<=(12 * strlen(sprintf("%d", $3))) ? $3 : sprintf("")) w labels left rotate font ",10" tc rgb "black" offset 0,0.1 notitle,\
for [i=n:0:-1] "<tail -24 ".file."" u (timecolumn(1)-600):((-($5)/n)*i):((-($5)/n)*i) w boxes lc palette notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5):( $5>0 && ($5/ymax*ptmax)> (12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5):( $5>0 && ($5/ymax*ptmax)<=(12 * strlen(sprintf("%d", $5))) ? -$5 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)-600):(-$5) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2) w boxes lc rgb "#5555ff" fillstyle solid notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2) w boxes lc rgb "black" fill empty notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2):( $2>0 && ($2/ymax*ptmax)> (12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels left rotate font ",10" tc rgb "white" offset 0,0.1 notitle,\
"<tail -24 ".file."" u (timecolumn(1)+600):(-$2):( $2>0 && ($2/ymax*ptmax)<=(12 * strlen(sprintf("%d", $2))) ? -$2 : sprintf("")) w labels right rotate font ",10" tc rgb "black" offset 0,-0.1 notitle
with the expected output of