No particular context
#!/bin/bash
gmt begin test png
vecsta=0
vecsto=$(gmt math -Q 6 PI MUL =)
vecste=$(gmt math -Q 1 32 DIV =)
# x
gmt math -T$vecsta/$vecsto/$vecste T -o0 = x.txt
# y = sin(x)
gmt math -Q x.txt SIN = y.txt
#y2 = A cos(x+B)
gmt math -Q x.txt PI 3 DIV ADD COS 4 PI MUL 10 DIV MUL = y2.txt
# Shading for red<blue
gmt math -Q y.txt y2.txt LE 0 NAN y.txt MUL = y_c.txt
# Shading for red>blue
gmt math -Q y.txt y2.txt GE 0 NAN y2.txt MUL = y2_c.txt
# All in one file (for -Sb+base option)
paste x.txt y.txt y2.txt y_c.txt y2_c.txt > file.txt
gmt plot file.txt -i0,1 -Wblue -R0/20/-2/2 -JX10c -l"@[\sin(x)@["
gmt plot file.txt -i0,2 -Wred -l"@[\frac{4\pi}{10}\cos(x+\frac{pi}{3})@["
gmt plot file.txt -i0,3,2 -Gred@90 -Sb${vecste}q+b -l"red > blue"
gmt plot file.txt -i0,4,1 -Gblue@90 -Sb${vecste}q+b -l"red < blue"
gmt basemap -Bxafpigpi -Byafg -BW+t"Relative anomaly" --MAP_FRAME_TYPE=graph
gmt basemap -Bxapi -BS -Y5c --MAP_FRAME_TYPE=graph
gmt end show
@pwessel : would be nice if there was an option in MAP_FRAME_TYPE
to get the x-axis arrow centered at 0 rather than resorting to -Y
(which messes up the auto-legend).