MATLAB: Is is possible to move the LEGEND in a figure once the ‘box’ is turned ‘off’ in MATLAB

MATLABmouse

I am trying to create a transparent bounding box for my legend in a figure. When I execute the following commands:
figure ; plot(1:10);
hl = legend('test', 'location', 'NorthEastOutside');
legend('boxoff')
I am unable to move the legend.

Best Answer

The ability to move the LEGEND when the BOX is turned 'off' is not available in MATLAB.
As a workaround, you can set the 'XColor', 'YColor' and 'Color' properties of the axes object appropriately. For example, see code below:
figure ; plot(1:10);
hl = legend('test', 'location', 'NorthEastOutside');
set(hl, 'XColor', 'w', 'YColor', 'w', 'Color', 'none');
This will make the legend axes transparent with white borders, and still allow the user to drag the legend in the figure.