How to plot a timeline

Ok, here is the GMT solution (had to play a little with the vertical offsets). And since we have no curly braces (would have to construct a custom symbol), I used a double arrow.

using GMT

basemap(region=(0,10,0,1), frame=(axes=:S, ticks=1), figsize=15, par=(MAP_FRAME_TYPE=:inside, MAP_TICK_LENGTH=0.5), y_off=5)
basemap!(frame=(axes=:S,), xaxis=(custom=(pos=[3; 4; 5; 6], type=["a t-2", "a t-1", "a t", "a t+1"]),), par=(MAP_FRAME_TYPE=:graph, MAP_VECTOR_SHAPE=1, MAP_TICK_LENGTH=0))
text!(text_record([10.5 0], "years"), font=12, justify=:CB, noclip=true, y_off=-0.5)
lines!([3 0; 4 0], pen=(16,200), y_off=-0.6)
lines!([4 0; 5 0], pen=(16,150))
lines!([5 0; 6 0], pen=(16,:green))
arrows!([6 0 0 1.5], arrow=(length="10p", stop=true), fill=:green, pen=(1,:green, :dashed), noclip=true, y_off=0.15)
arrows!([5 0 0 1.5], arrow=(length="4p", start=true, stop=true), lw=0.5, noclip=true, fill=:black, y_off=-0.4)
text!(text_record([5.5 0], "Testing period"), font=12, justify=:CB, noclip=true, y_off=-0.6)
# Now the upper side
lines!([1 0; 2 0], pen=(16,200), y_off=2.6)
lines!([2 0; 3 0], pen=(16,150))
lines!([3 0; 4 0], pen=(16,[150 100 100]))
lines!([4 0; 5 0], pen=(16,:red))
arrows!([5 0 0 1.5], arrow=(length="10p", stop=true), fill=:red, pen=(1,:red, :dashed), noclip=true, y_off=0.15)
arrows!([3 0 0 3.0], arrow=(length="4p", start=true, stop=true), lw=0.5, noclip=true, fill=:black, y_off=0.4)
text!(text_record([4.0 0], "Training period"), font=12, justify=:CB, noclip=true, y_off=0.3, fmt=:png, savefig="timeline", show=true)

6 Likes