The legend function will return as the second output argument for all components that make up the characters and text in the legend. Therefore, you can build dummy strings as placeholders in the legend, change the order of the pens when creating the legend, to place the text where you want, and change the legend objects accordingly. Here is an example:
x = linspace(0, 2*pi, 100); hl = plot(x, [sin(x); cos(x); tan(x); nan(size(x))].'); % Add a line of NaNs axis([0 2*pi -4 4]); [~, objH] = legend(hl([1 2 4 3]), 'sin', 'cos', 'junk', 'tan'); % Reorder handles set(findobj(objH, 'Tag', 'junk'), 'Vis', 'off'); % Make "junk" lines invisible pos = get(objH(3), 'Pos'); % Get text box position set(objH(3), 'Pos', [0.1 pos(2:3)], 'String', 'also...'); % Stretch box and change text

source share