slight changes to external source to save plots in pdf