code for the figures in the example section