Problem with time format on x-as not displaying correctly












4














I've made a 24 hour graphic (with different y-axes). So far so good.



But the x-axe is not displaying as I wanted.



1/ the time is not displayed correctly 05:59:00 instead of 06:00:00



2/ the x-axe should stop at 24:00:00 (now it goes further).



Any help would be appreciated.



My code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here










share|improve this question


















  • 1




    Isn't there a typo: xmin=00:00:00, ymax=24:00:00, should probably be xmin=00:00:00, xmax=24:00:00,. BTW, use "axis" instead of "axe" (or use an ice axe ;-).
    – marmot
    Dec 13 '18 at 14:13


















4














I've made a 24 hour graphic (with different y-axes). So far so good.



But the x-axe is not displaying as I wanted.



1/ the time is not displayed correctly 05:59:00 instead of 06:00:00



2/ the x-axe should stop at 24:00:00 (now it goes further).



Any help would be appreciated.



My code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here










share|improve this question


















  • 1




    Isn't there a typo: xmin=00:00:00, ymax=24:00:00, should probably be xmin=00:00:00, xmax=24:00:00,. BTW, use "axis" instead of "axe" (or use an ice axe ;-).
    – marmot
    Dec 13 '18 at 14:13
















4












4








4







I've made a 24 hour graphic (with different y-axes). So far so good.



But the x-axe is not displaying as I wanted.



1/ the time is not displayed correctly 05:59:00 instead of 06:00:00



2/ the x-axe should stop at 24:00:00 (now it goes further).



Any help would be appreciated.



My code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here










share|improve this question













I've made a 24 hour graphic (with different y-axes). So far so good.



But the x-axe is not displaying as I wanted.



1/ the time is not displayed correctly 05:59:00 instead of 06:00:00



2/ the x-axe should stop at 24:00:00 (now it goes further).



Any help would be appreciated.



My code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, ymax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00,12:00:00,18:00:00,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here







tikz-pgf pgfplots






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 13 '18 at 14:10









Arne Timperman

2,3721636




2,3721636








  • 1




    Isn't there a typo: xmin=00:00:00, ymax=24:00:00, should probably be xmin=00:00:00, xmax=24:00:00,. BTW, use "axis" instead of "axe" (or use an ice axe ;-).
    – marmot
    Dec 13 '18 at 14:13
















  • 1




    Isn't there a typo: xmin=00:00:00, ymax=24:00:00, should probably be xmin=00:00:00, xmax=24:00:00,. BTW, use "axis" instead of "axe" (or use an ice axe ;-).
    – marmot
    Dec 13 '18 at 14:13










1




1




Isn't there a typo: xmin=00:00:00, ymax=24:00:00, should probably be xmin=00:00:00, xmax=24:00:00,. BTW, use "axis" instead of "axe" (or use an ice axe ;-).
– marmot
Dec 13 '18 at 14:13






Isn't there a typo: xmin=00:00:00, ymax=24:00:00, should probably be xmin=00:00:00, xmax=24:00:00,. BTW, use "axis" instead of "axe" (or use an ice axe ;-).
– marmot
Dec 13 '18 at 14:13












1 Answer
1






active

oldest

votes


















4














After fixing the typos in xmax (which were typed as ymax twice) and a tiny bit of cheating (I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00}, i.e. increased 6am and 6pm by 0.5 seconds; I guess there is a rounding issue somewhere) I arrive at



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here






share|improve this answer























  • why on earth do I have fat finger syndrome (xmax vs ymax), thanx
    – Arne Timperman
    Dec 13 '18 at 14:44






  • 1




    @ArneTimperman It is certainly not easier when you are born with claws. ;-)
    – marmot
    Dec 13 '18 at 14:48










  • I've copied your code, because I couldn't find what you had changed, besides the x and y
    – Arne Timperman
    Dec 13 '18 at 14:54






  • 1




    @ArneTimperman Oh, I should have said explicitly: I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},, i.e. increased 6am and 6pm by 0.5 seconds. I guess there is a rounding issue somewhere.
    – marmot
    Dec 13 '18 at 14:55











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464709%2fproblem-with-time-format-on-x-as-not-displaying-correctly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














After fixing the typos in xmax (which were typed as ymax twice) and a tiny bit of cheating (I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00}, i.e. increased 6am and 6pm by 0.5 seconds; I guess there is a rounding issue somewhere) I arrive at



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here






share|improve this answer























  • why on earth do I have fat finger syndrome (xmax vs ymax), thanx
    – Arne Timperman
    Dec 13 '18 at 14:44






  • 1




    @ArneTimperman It is certainly not easier when you are born with claws. ;-)
    – marmot
    Dec 13 '18 at 14:48










  • I've copied your code, because I couldn't find what you had changed, besides the x and y
    – Arne Timperman
    Dec 13 '18 at 14:54






  • 1




    @ArneTimperman Oh, I should have said explicitly: I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},, i.e. increased 6am and 6pm by 0.5 seconds. I guess there is a rounding issue somewhere.
    – marmot
    Dec 13 '18 at 14:55
















4














After fixing the typos in xmax (which were typed as ymax twice) and a tiny bit of cheating (I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00}, i.e. increased 6am and 6pm by 0.5 seconds; I guess there is a rounding issue somewhere) I arrive at



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here






share|improve this answer























  • why on earth do I have fat finger syndrome (xmax vs ymax), thanx
    – Arne Timperman
    Dec 13 '18 at 14:44






  • 1




    @ArneTimperman It is certainly not easier when you are born with claws. ;-)
    – marmot
    Dec 13 '18 at 14:48










  • I've copied your code, because I couldn't find what you had changed, besides the x and y
    – Arne Timperman
    Dec 13 '18 at 14:54






  • 1




    @ArneTimperman Oh, I should have said explicitly: I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},, i.e. increased 6am and 6pm by 0.5 seconds. I guess there is a rounding issue somewhere.
    – marmot
    Dec 13 '18 at 14:55














4












4








4






After fixing the typos in xmax (which were typed as ymax twice) and a tiny bit of cheating (I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00}, i.e. increased 6am and 6pm by 0.5 seconds; I guess there is a rounding issue somewhere) I arrive at



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here






share|improve this answer














After fixing the typos in xmax (which were typed as ymax twice) and a tiny bit of cheating (I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00}, i.e. increased 6am and 6pm by 0.5 seconds; I guess there is a rounding issue somewhere) I arrive at



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{comment}
usepackage{filecontents}
usepackage{geometry}
usepackage{tikz}

usepgfplotslibrary{dateplot}
defremoveleadingzeros#1{if0#1 expandafterelse#1fi}

deftransformtime#1:#2:#3!{
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
%pgfmathparse{#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+#2*60+#3}
pgfmathparse{removeleadingzeros#1*3600-pgfkeysvalueof{/pgfplots/timeplot zero}*3600+removeleadingzeros#2*60+removeleadingzeros#3}
pgfkeys{/pgf/fpu=false}
}


pgfplotsset{
timeplot zero/.initial=0,
timeplot/.style={
x coord trafo/.code={expandaftertransformtime##1!},
x coord inv trafo/.code={%
pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
pgfmathsetmacrohours{floor(##1/3600)+pgfkeysvalueof{/pgfplots/timeplot zero}}
pgfmathsetmacrominutes{floor((##1-(hours-pgfkeysvalueof{/pgfplots/timeplot zero})*3600)/60)}
pgfmathsetmacroseconds{##1-floor(##1/60)*60}
defpgfmathresult{pgfmathparse{mod(hours,60)<10?"0":{},int(mod(hours,60))}pgfmathresult:pgfmathparse{mod(minutes,60)<10?"0":{},int(mod(minutes,60))}pgfmathresult:pgfmathparse{mod(seconds,60)<10?"0":{},int(mod(seconds,60))}pgfmathresult}
pgfkeys{/pgf/fpu=false}
},
scaled x ticks=false,
xticklabel=tick
}
}
begin{document}


begin{filecontents*}{boom.dat}
tijd diameter
00:00:00 656.405681
00:15:00 656.410403
00:30:00 656.415722
00:45:00 656.419879
01:00:00 656.422925
01:15:00 656.425762
01:30:00 656.429439
01:45:00 656.432858
02:00:00 656.435443
02:15:00 656.437564
02:30:00 656.438722
02:45:00 656.441318
03:00:00 656.443924
03:15:00 656.446608
03:30:00 656.449341
03:45:00 656.450762
04:00:00 656.451835
04:15:00 656.453
04:30:00 656.454701
04:45:00 656.456525
05:00:00 656.458294
05:15:00 656.460722
05:30:00 656.462619
05:45:00 656.464791
06:00:00 656.466648
06:15:00 656.467714
06:30:00 656.469632
06:45:00 656.470793
07:00:00 656.471614
07:15:00 656.47177
07:30:00 656.472144
07:45:00 656.472204
08:00:00 656.472353
08:15:00 656.471947
08:30:00 656.471044
08:45:00 656.467682
09:00:00 656.45527
09:15:00 656.438903
09:30:00 656.422273
09:45:00 656.41521
10:00:00 656.408804
10:15:00 656.402313
10:30:00 656.393826
10:45:00 656.385612
11:00:00 656.378146
11:15:00 656.372256
11:30:00 656.367282
11:45:00 656.361468
12:00:00 656.355557
12:15:00 656.350256
12:30:00 656.343752
12:45:00 656.337133
13:00:00 656.332531
13:15:00 656.32958
13:30:00 656.328682
13:45:00 656.327219
14:00:00 656.321448
14:15:00 656.315754
14:30:00 656.312755
14:45:00 656.311984
15:00:00 656.31289
15:15:00 656.313705
15:30:00 656.316576
15:45:00 656.323175
16:00:00 656.327068
16:15:00 656.326734
16:30:00 656.329307
16:45:00 656.34159
17:00:00 656.344922
17:15:00 656.344023
17:30:00 656.34417
17:45:00 656.344636
18:00:00 656.345115
18:15:00 656.344474
18:30:00 656.344168
18:45:00 656.34317
19:00:00 656.343425
19:15:00 656.343974
19:30:00 656.345429
19:45:00 656.351991
20:00:00 656.361141
20:15:00 656.366497
20:30:00 656.374289
20:45:00 656.381799
21:00:00 656.389487
21:15:00 656.395972
21:30:00 656.402692
21:45:00 656.408891
22:00:00 656.416834
22:15:00 656.422846
22:30:00 656.428715
22:45:00 656.435375
23:00:00 656.441634
23:15:00 656.445468
23:30:00 656.449594
23:45:00 656.452806
end{filecontents*}



begin{filecontents*}{sapstroom.dat}
tijd sapstroom
00:00:00 4.85408
00:15:00 4.57286
00:30:00 4.39551
00:45:00 4.4178
01:00:00 4.04949
01:15:00 3.77214
01:30:00 3.62084
01:45:00 3.46315
02:00:00 3.28671
02:15:00 3.21523
02:30:00 3.13485
02:45:00 2.97071
03:00:00 2.88493
03:15:00 2.96935
03:30:00 2.48116
03:45:00 2.45723
04:00:00 2.38146
04:15:00 2.37392
04:30:00 2.48235
04:45:00 2.28593
05:00:00 2.23122
05:15:00 2.20008
05:30:00 2.13761
05:45:00 2.05941
06:00:00 1.95399
06:15:00 1.90721
06:30:00 1.79834
06:45:00 1.77564
07:00:00 1.86757
07:15:00 2.13706
07:30:00 2.75334
07:45:00 3.49142
08:00:00 4.59272
08:15:00 6.20182
08:30:00 8.13804
08:45:00 10.2965
09:00:00 12.6352
09:15:00 14.649
09:30:00 16.9704
09:45:00 18.306
10:00:00 19.6905
10:15:00 20.6927
10:30:00 21.2783
10:45:00 21.9715
11:00:00 22.2801
11:15:00 22.4729
11:30:00 22.697
11:45:00 22.5211
12:00:00 22.9484
12:15:00 22.9198
12:30:00 22.9355
12:45:00 23.1047
13:00:00 23.0004
13:15:00 23.0681
13:30:00 22.7262
13:45:00 22.7039
14:00:00 23.0067
14:15:00 23.2884
14:30:00 23.2097
14:45:00 22.9358
15:00:00 22.478
15:15:00 21.9537
15:30:00 21.1719
15:45:00 21.2557
16:00:00 21.1705
16:15:00 22.4717
16:30:00 21.3172
16:45:00 19.8637
17:00:00 20.242
17:15:00 21.574
17:30:00 21.7862
17:45:00 21.4883
18:00:00 21.0291
18:15:00 20.684
18:30:00 20.9946
18:45:00 21.6095
19:00:00 21.0845
19:15:00 20.2188
19:30:00 19.1834
19:45:00 18.3425
20:00:00 17.5752
20:15:00 17.0377
20:30:00 15.6622
20:45:00 14.5367
21:00:00 13.3425
21:15:00 11.8389
21:30:00 10.4741
21:45:00 9.53448
22:00:00 8.7462
22:15:00 7.98585
22:30:00 7.51326
22:45:00 7.01831
23:00:00 6.48857
23:15:00 5.97139
23:30:00 5.63499
23:45:00 5.26984
end{filecontents*}


begin{tikzpicture}
begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=656.3, ymax=656.5,
title=Boomdiagram,
xlabel=Tijdstip,
ylabel=Diameter (mm),
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
%minor xtick={00:15:00,00:30:00,00:45:00,01:00:00,01:15:00,01:30:00,01:45:00},
minor ytick={656.1,656.32,...,656.48},
grid=both,
width=linewidth,
%height=8cm,
y tick label style={/pgf/number format/fixed, /pgf/number format/precision=2, /pgf/number format/fixed zerofill},
tick label style={font=small},
x tick label style={rotate=-90},
]
addplot[blue,mark=*,mark size=1] table [x=tijd, y=diameter] {boom.dat}; label{plot_one}
addlegendentry{Diameter}
end{axis}



begin{axis}[
%axis lines=center,
xmin=00:00:00, xmax=24:00:00,
ymin=0, ymax=25,
title=Boomdiagram,
xlabel=Tijdstip,
axis y line*=right,
ylabel=Sapstroom,
ylabel near ticks,
xlabel near ticks,
timeplot, timeplot zero=0,
xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},
grid=both,
width=linewidth,
%height=8cm,
x tick label style={rotate=-90},
tick label style={font=small},
]
addplot[red,mark=triangle*] table [x=tijd, y=sapstroom] {sapstroom.dat};label{plot_two}
addlegendimage{/pgfplots/refstyle=plot_one}addlegendentry{Sapstroom}
addlegendentry{Boomdiameter}

end{axis}


end{tikzpicture}


end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 13 '18 at 16:21

























answered Dec 13 '18 at 14:24









marmot

88k4101189




88k4101189












  • why on earth do I have fat finger syndrome (xmax vs ymax), thanx
    – Arne Timperman
    Dec 13 '18 at 14:44






  • 1




    @ArneTimperman It is certainly not easier when you are born with claws. ;-)
    – marmot
    Dec 13 '18 at 14:48










  • I've copied your code, because I couldn't find what you had changed, besides the x and y
    – Arne Timperman
    Dec 13 '18 at 14:54






  • 1




    @ArneTimperman Oh, I should have said explicitly: I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},, i.e. increased 6am and 6pm by 0.5 seconds. I guess there is a rounding issue somewhere.
    – marmot
    Dec 13 '18 at 14:55


















  • why on earth do I have fat finger syndrome (xmax vs ymax), thanx
    – Arne Timperman
    Dec 13 '18 at 14:44






  • 1




    @ArneTimperman It is certainly not easier when you are born with claws. ;-)
    – marmot
    Dec 13 '18 at 14:48










  • I've copied your code, because I couldn't find what you had changed, besides the x and y
    – Arne Timperman
    Dec 13 '18 at 14:54






  • 1




    @ArneTimperman Oh, I should have said explicitly: I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},, i.e. increased 6am and 6pm by 0.5 seconds. I guess there is a rounding issue somewhere.
    – marmot
    Dec 13 '18 at 14:55
















why on earth do I have fat finger syndrome (xmax vs ymax), thanx
– Arne Timperman
Dec 13 '18 at 14:44




why on earth do I have fat finger syndrome (xmax vs ymax), thanx
– Arne Timperman
Dec 13 '18 at 14:44




1




1




@ArneTimperman It is certainly not easier when you are born with claws. ;-)
– marmot
Dec 13 '18 at 14:48




@ArneTimperman It is certainly not easier when you are born with claws. ;-)
– marmot
Dec 13 '18 at 14:48












I've copied your code, because I couldn't find what you had changed, besides the x and y
– Arne Timperman
Dec 13 '18 at 14:54




I've copied your code, because I couldn't find what you had changed, besides the x and y
– Arne Timperman
Dec 13 '18 at 14:54




1




1




@ArneTimperman Oh, I should have said explicitly: I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},, i.e. increased 6am and 6pm by 0.5 seconds. I guess there is a rounding issue somewhere.
– marmot
Dec 13 '18 at 14:55




@ArneTimperman Oh, I should have said explicitly: I changed the xticks to xtick={00:00:00,06:00:00.5,12:00:00,18:00:00.5,24:00:00},, i.e. increased 6am and 6pm by 0.5 seconds. I guess there is a rounding issue somewhere.
– marmot
Dec 13 '18 at 14:55


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464709%2fproblem-with-time-format-on-x-as-not-displaying-correctly%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?