code to produce pdf for figure 2