do some more refactoring on the plotting scripts