Often I need to optimize a complex plot in many iterations, an example would be finding a good position for the legend. Let\'s say my code looks something like this: