Legend is plotted next to the figure
Added option MAX_NUM_QP_ITERATIONS