xsize=14.65
ysize=12.5
size xsize ysize

pt=0.0352777778 ! 1 postscript point

fs=12*pt  !font size
tt=4*pt   !tick length
lw=0.5*pt !line width
glw=2*lw  !graph line width
ms=4*pt   !marker size

set lwidth lw
set hei fs
set texscale scale
set just cc

begin texpreamble
    % set fonts used for text and maths to Palatino
    \usepackage{mathpazo}
    \renewcommand{\familydefault}{ppl}
    \usepackage{upgreek}
    \usepackage[load=abbr]{siunitx}
    \usepackage{bm}
    \usepackage{textcomp}
    \newcommand{\murm}{%
      \ifmmode
        \mathchoice
            {\hbox{\normalsize\textmu}}
            {\hbox{\normalsize\textmu}}
            {\hbox{\scriptsize\textmu}}
            {\hbox{\tiny\textmu}}%
      \else
        \textmu
      \fi
    }
end texpreamble

scalefactor=0.32
diagxsize=27
diagysize=14

yoffset=6

diagyoffset=1.3

amove diagxsize*scalefactor+2 diagysize*scalefactor*0.5+yoffset+diagyoffset
rline 1.5 0 arrow start

set color rgb255(255/1.2,209/1.2,35/1.2)
rmove 0.3 0
tex "\murm $^+$"
set color black

amove 1 yoffset+diagyoffset
postscript "anim-000.eps" diagxsize*scalefactor diagysize*scalefactor
rmove -0.5 diagysize*scalefactor-12*pt
tex "(a)"
amove 1 diagyoffset
postscript "anim-011.eps" diagxsize*scalefactor diagysize*scalefactor
rmove -0.5 diagysize*scalefactor-12*pt
tex "(b)"

xgraphsize=5
ygraphsize=3.5
ygraphoffset=2.7

xmn=0
xmx=4
xticks=1
xsubticks=0.5
ymn=0
ymx=1
yticks=0.5
ysubticks=0.1

pztmn=-1.1
pztmx=1.1
pztticks=1
pztsubticks=0.5

omega=2
tau_mu=2.2


i=0

!set the time correctly for the various graphs
if i=0 then t=11/300*5

amove 1+diagxsize*scalefactor+0.5 yoffset*i+0.5+ygraphoffset
begin graph
    size xgraphsize ygraphsize
    nobox
    
    let d1=exp(-(x/tau_mu))*(2/3+1/3*cos(omega*x)) from 0 to t step 0.01
    let d2=exp(-(x/tau_mu))*(2/3-1/3*cos(omega*x)) from 0 to t step 0.01
    let d3=2/3*exp(-(x/tau_mu)) from 0 to t step 0.01
    
    let d4=exp(-(x/tau_mu))*(2/3+1/3*cos(omega*x)) from t to t+0.0001 step 1
    let d5=exp(-(x/tau_mu))*(2/3-1/3*cos(omega*x)) from t to t+0.0001 step 1
    let d6=2/3*exp(-(x/tau_mu)) from t to t+0.0001 step 1
    
    !xtitle "\tex{$t$ (\si{\us})}"
    xaxis min xmn max xmx dticks xticks dsubticks xsubticks
    xaxis format "round 9 nozeroes prepend \tex{$ append $}" ! makes axis labels TeX. dec is just padding, because for some reason it doesn't work if prepend or append is first
    xticks length ticklength
    xlabels off
    
    ytitle "\tex{counts (arb.)}" dist 0.1
    yaxis min ymn max ymx dticks yticks dsubticks ysubticks !nolast
    yaxis format "round 9 nozeroes prepend \tex{$ append $}" ! makes axis labels TeX. dec is just padding, because for some reason it doesn't work if prepend or append is first
    yticks length ticklength
    ylabels off
    
    d1 lstyle 1 lwidth glw color rgb255(48,80,248)
    d2 lstyle 1 lwidth glw color rgb(1,0.05098,0.05098)
    d3 lstyle 3 lwidth glw color rgb255(144,224,80)
    
    d4 marker fcircle msize ms color rgb255(48,80,248)
    d5 marker fcircle msize ms color rgb(1,0.05098,0.05098)
    d6 marker fcircle msize ms color rgb255(144,224,80)
end graph

rmove  0 -ygraphoffset
begin graph
    size xgraphsize ygraphsize
    nobox
    
    let d1=cos(omega*x) from 0 to t step 0.01
    let d2=cos(omega*x) from t to t+0.0001 step 1
    
    !xtitle "\tex{$t$ (\si{\us})}"
    xaxis min xmn max xmx dticks xticks dsubticks xsubticks
    xaxis format "round 9 nozeroes prepend \tex{$ append $}" ! makes axis labels TeX. dec is just padding, because for some reason it doesn't work if prepend or append is first
    xticks length ticklength
    xlabels off
    !xsubticks off
    
    ytitle "\tex{$p_{z}(t)$}" dist 0.001
    yaxis min pztmn max pztmx dticks pztticks dsubticks pztsubticks !nolast
    yaxis format "round 9 nozeroes prepend \tex{$ append $}" ! makes axis labels TeX. dec is just padding, because for some reason it doesn't work if prepend or append is first
    yticks length ticklength
    
    d1 lstyle 1 lwidth glw color rgb255(144,224,80)
    d2 marker fcircle msize ms color rgb255(144,224,80)
end graph

if i=0 then
begin graph
    size xgraphsize ygraphsize
    nobox
    
    xtitle "\tex{$t$ (\si{\us})}"
    xaxis min xmn max xmx dticks xticks dsubticks xsubticks
    xaxis format "round 9 nozeroes prepend \tex{$ append $}" ! makes axis labels TeX. dec is just padding, because for some reason it doesn't work if prepend or append is first
    xside off
    xticks off
    
    yaxis off
end graph
end if