I have 6 legend items and I want to split the legend as 2*3. I am using Matlab 2016a
Best Answer
On newer versions of MATLAB, you can set the NumColumns property of legends to get a 2x3 legend. However, in older versions, you can get two legends by adding a hidden axes. For example, the following code shows one of the ways.
ax = axes();
hold(ax);
ax2 = axes('Visible', 'off');
hold(ax2);
x = 1:10;
y = 1:10;
plot(ax, x,y, x,y+1, x,y+2);
plot(ax2, x,y+3, x,y+4, x,y+5);
% adjust the axis of hidden and visible axes to have same limits
Best Answer