@Walter Roberson Thank you for your guidance, your code still gives me indexing errors, but I believe that I have managed to solve it. It required making an extra variable for the plot function as well and indexing to that specific variable in an array concatenation.
colororder({'k','k'})
barLegend = {'Iceland', 'England', 'Spain'};
totalLegend = cell(1, numel(barLegend) + 1);
for i = 1:numel(barLegend)
totalLegend{i} = [barLegend{i} ' Temperature'];
end
totalLegend{end} = 'GDP';
b = [1:4; 10:13; 21:24];
a = [74 68 63 56];
x = [1:4];
yyaxis left
h = bar(x, b, 'stacked');
order = [3 2 1 4];
colororder('default')
grid on
grid minor
hold on
yyaxis right
p = plot(x, a);
legend([h(order(1:end-1)), p(1)], [totalLegend(order(1:end-1)), ...
totalLegend(order(end))], 'Location', 'best')
