matlab

How to add a legend without plot rescaling?


I'm using a figure having 4 subplots. For the first plot I need to add a legend. But when I add it, the first plot is rescaled.

I don't want to specify location using set() due to the fact the sublots' number may change on the same figure.

This is how I add the legend:

legend('Constant','Adaptive','Location','northoutside','Orientation','horizontal');

This is my current figure. enter image description here


Solution

  • By dragging/dropping the legend with your mouse out of the axes, Matlab sets the axes location back to its initial position.

    Even if the resize is automatic after the drag&drop, I've not found a solution that does not make use of the mouse though. For a single or a few plots, this trick will make it I think.