Changed all R files to open graphics file before plotting
(Instead of copying plot from display, which messed up the legend)