merging plotting code from old and new trial plots