Made a more complicated function to integrate in the trial.
Moved the pos. of the legend.
Merged Linton's changes.