xsize=10
ysize=9
size xsize ysize

begin texpreamble
    % set fonts used for text and maths to Palatino
    \usepackage{mathpazo}
    \renewcommand{\familydefault}{ppl}
    \usepackage{upgreek}
    \usepackage[load=abbr]{siunitx}
    \usepackage{bm}
end texpreamble

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 hei fs
set texscale scale
set lwidth lw
set just tl

xgraphsize=xsize
ygraphsize=6
yspace=0.5


! canting diagram arrows

startx=3.5
starty=7.9
arrowspace=2
arrowheight=2
tickheight=2
arcrad=0.4
alphamovex=0.24
alphamovey=-0.05
angle=30
pi=3.1415926535
angler=angle/180*pi

set color black
amove 1.1 starty+1
text \tex{\footnotesize{(a)}}


amove startx-arrowheight*tan(angler)/2 starty-arrowheight/2-0.1
rline arrowheight*tan(angler) 0 arrow both
amove startx starty-arrowheight/2-0.45
set just bc
set hei 8*pt
text \tex{$0.2\mu _{\mathrm{B}}$}
set color rgb(0.372549,0.619608,0.803922)
amove startx-alphamovex starty-arrowheight/2-alphamovey
text \tex{$\alpha$}
set lstyle 1
amove startx-arrowheight*tan(angler)/2-0.15 starty-arrowheight/2
rline 0 arrowheight arrow end
amove startx-arrowheight*tan(angler)/2-0.4 starty
set just cc
text \tex{$\hat{\bm{m}}$}

amove startx starty
set color rgb(0.372549,0.619608,0.803922)
arc arcrad 90-angle 90
arc arcrad 270-angle 270
set color rgb255(0.7,0.7,0.7)
rmove 0 -tickheight/2
rline 0 tickheight
set color rgb(0.082353,0.258824,0.388235)

rmove -arrowheight*tan(angler)/2 -tickheight
rline arrowheight*tan(angler) arrowheight arrow end
rmove 0.1 0
text \tex{$\bm{\mu}$}

angle=360-angle
angler = angle/180*3.1415926535

amove startx+arrowspace starty
set color rgb(0.8,0.8,0.8)
rmove 0 -tickheight/2
rline 0 tickheight

set color rgb255(0.082353,0.258824,0.388235)
rmove -arrowheight*tan(angler)/2 -tickheight
rline arrowheight*tan(angler) arrowheight arrow start

amove startx+arrowspace starty
set color rgb(0.372549,0.619608,0.803922)
circle arcrad/3 fill white
circle arcrad/10 fill rgb(0.372549,0.619608,0.803922)
set just bl
rmove 0.15 0.15
text \tex{$\hat{\bm{n}}$}

set color black



! graph settings
xmn=0
xmx=90
xticks=10
xsubticks=5
ymn=0
ymx=0.5
yticks=0.1
ysubticks=0.05

ticklength=0.1

!waterfalloffset=2

glw=2*lw
errw=glw/2
ms=2*pt ! marker size


include "color.gle"

!! uncomment the following to replot the colour map
!begin fitz
!    data "Ba2NaOsO6-001-cant-010-3d-mu-histo.tsv"
!    x from 0 to 90 step 1
!    y from 0 to 0.5 step 0.01
!end fitz

amove 0 0
begin graph
    size xgraphsize ygraphsize
    scale auto
    nobox

    xtitle "\tex{$\alpha$ (\si{\degree})}"
    ! alpha is mis-defined in this, needs to be 90-alpha. Easier than rearranging all the files...
    xplaces 0 10 20 30 40 50 60 70 80 90
    xnames \tex{$90$} \tex{$80$} \tex{$70$} \tex{$60$} \tex{$50$} \tex{$40$} \tex{$30$} \tex{$20$} \tex{$10$} \tex{$0$}
    xticks length tt

    ytitle "\tex{$\mu$ ($\mu _{\mathrm{B}}$)}"
    yaxis min ymn max ymx dticks yticks dsubticks ysubticks
    yaxis format "round 1 prepend \tex{$ append $}"
    yticks length tt
    
    colormap "Ba2NaOsO6-001-cant-010-3d-mu-histo.z" 800 800 invert zmin 0 zmax 10
    data Ba2NaOsO6-001-cant-010-3d-mu-means.tsv d1=c1,c2
    data Ba2NaOsO6-001-cant-010-3d-mu-medians.tsv d2=c1,c2 d3=c1,c3 d4=c1,c4
    data Ba2NaOsO6-001-cant-010-3d-mu-modes.tsv d5=c1,c2
    !d1 line lwidth lw color rgb255(255,13,13)
    d2 line lwidth lw color rgb255(255,13,13)
    d3 lstyle 5 lwidth lw color rgb255(255,13,13)
    d4 lstyle 5 lwidth lw color rgb255(255,13,13)
    !d5 line lwidth lw color magenta
    
    let d10=0.19/cos(x/180*3.1415926535)
    let d11=0.21/cos(x/180*3.1415926535)
    d10 lstyle 3 color rgb255(48,80,248)
    d11 lstyle 3 color rgb255(48,80,248)
end graph

begin key
 nobox
 position tl
 offset 0 0
 text "\tex{(b)}"
end key

!amove 13 1.75
!color_range_vertical 0 1.5 0.3 pixels 1500

amove 0.9 6.1
text \tex{FM}
rmove 8.3 0
text \tex{AFM}