Legend Placement in Nested Tile Layout
Show older comments
Here is the figure my code currently creates:

I want to produce exaclty this same figure, but with the legend in the bottom middle, rather than the bottom. As I understand it, the problem is that legend takes in the axes for the second tile in the nested layout as its position argument. I think I need to use a nested tiled layout in order to get a title for each column (currently "test1" and test2").
My code is paasted below. I really appreciate any help/suggestions!
figure('Position', [0, 0, 1200, 600]); % Adjust the size as needed
T=tiledlayout(1, length(cdfs_in)); %
for i=1:length(cdfs_in)
t=tiledlayout(T,2,1);
title(t, titles(i));
t.Layout.Tile = i;
t.Layout.TileSpan = [1 1];
t.TileSpacing = 'compact';
nexttile(t);
plot(soph, utils_sinc(:,1,i))
hold on
plot(soph, utils_sinc(:,2,i))
hold on
plot(soph, utils_sinc(:,3,i))
hold off
ylabel("Mean Utility", 'FontSize', 12);
xlabel("Fraction of Students who are Sophisticated (P_{soph})", 'FontSize', 12);
title("Sincere Students", 'FontWeight', 'normal');
nexttile(t)
plot(soph, utils_tot(:,1,i))
hold on
plot(soph, utils_tot(:,2,i))
hold on
plot(soph, utils_tot(:,3,i))
hold off
title("All Students", 'FontWeight', 'normal');
xlabel("Fraction of Students who are Sophisticated (P_{soph})", 'FontSize', 12);
ylabel("Mean Utility", 'FontSize', 12);
end
lgd = legend('Optimal Taiwan Mechanism', 'Boston Mechanism', 'Deferred Acceptance', 'location', 'Best');
lgd.Layout.Tile = 'south';
Accepted Answer
More Answers (0)
Categories
Find more on Axes Appearance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
