I have the following plot:
y1 = [2,2,2,2];y2 = [2.15, 2.115, 2.08, 2.07];y3 = [0.08532, 0.071189, 0.05391, 0.06123];y11 = [2,2,2,2];y22 = [2.19,2.13,2.09,2.07];y33= [0.1134, 0.1233,0.1122,0.1202];y111 = [2,2,2,2];y222 = [2.19,2.15,2.09,2.1];y333= [0.1834, 0.1433,0.1622,0.1802];x = [1:4];h = figure;subplot(1,3,1)plot(x,y1,'*-r', 'LineWidth', 1)hold onplot(x, y2, '*-k', 'LineWidth',1)hold onplot(x, y3, '*-b', 'LineWidth',1)hold onplot(4.5, 2.08,'r.', 'MarkerSize', 20)hold onplot(4.5, 2.03,'k.', 'MarkerSize', 20)hold onplot(4.5, 0.0146331392,'b.', 'MarkerSize', 20)box onhold onxticklabels({'Jan 7','Jan 14','Jan 21','Jan 28'})xtickangle(45)%ylim([-0.05 0.15])
title('January 2005')set(gca,'Units','normalized')titleHandle = get( gca ,'Title' );pos = get(titleHandle , 'position' );pos1 = pos + [0 0.005 0] set(titleHandle , 'position' , pos1);legend('EONIA', 'EU Shadow Rate', 'Textual', 'Actual EONIA', 'Actual Shadow', 'Actual Textual','Orientation', 'horizontal', 'Location', 'southoutside', 'NumColumns',2)subplot(1,3,2)plot(x,y11,'*-r', 'LineWidth', 1)hold onplot(x, y22, '*-k', 'LineWidth',1)hold onplot(x, y33, '*-b', 'LineWidth',1)hold onplot(4.5,2.08,'r.', 'MarkerSize', 20)hold onplot(4.5,2.05,'k.', 'MarkerSize', 20)hold onplot(4.5,0.0938280876,'b.', 'MarkerSize', 20)box onhold onxticklabels({'April 7','April 14','April 21','April 28'})xtickangle(45)title('April 2005')set(gca,'Units','normalized')titleHandle = get( gca ,'Title' );pos = get(titleHandle , 'position' );pos1 = pos + [0 0.005 0] set(titleHandle , 'position' , pos1);legend('EONIA', 'EU Shadow Rate', 'Textual', 'Actual EONIA', 'Actual Shadow', 'Actual Textual', 'Orientation', 'horizontal', 'Location', 'southoutside', 'NumColumns',2)subplot(1,3,3)plot(x,y111,'*-r', 'LineWidth', 1)hold onplot(x, y222, '*-k', 'LineWidth',1)hold onplot(x, y333, '*-b', 'LineWidth',1)hold online1 = plot(4.5,2.08,'r.', 'MarkerSize', 20)hold online2 =plot(4.5,1.98,'k.', 'MarkerSize', 20)hold online3 =plot(4.5,0.2170966370,'b.', 'MarkerSize', 20)box onhold onxticklabels({'Aug 7','Aug 14','Aug 21','Aug 28'})xtickangle(45)title('August 2005')set(gca,'Units','normalized')titleHandle = get( gca ,'Title' );pos = get(titleHandle , 'position' );pos1 = pos + [0 0.005 0] set(titleHandle , 'position' , pos1);legend('EONIA', 'EU Shadow Rate', 'Textual', 'Actual EONIA', 'Actual Shadow', 'Actual Textual', 'Orientation', 'horizontal', 'Location', 'southoutside', 'NumColumns',2)
In the plot, I have 3 legends for each plot which are identical. I would like to have one unique legend below and outside (centred) the plots. I have read suggestions around but I couldn't make it work.
Can anyone help me with this?
Thanks!
Best Answer