functions to generate plots and save as pdf