MATLAB: Errorbar + multiple plots + one legend

axiserrobarlegendmultipleplots

For 'plot' function it is possible to 'merge' legends by integrating into a vector:
a = plot(rand(4));
hold on
b = plot(rand(4));
legend([a; b], {'a', 'b', 'c', 'd', 'a2', 'b2', 'c2', 'd2'});
But for errorbar plots it doesn work:
a = errorbar(rand(4),rand(4));
hold on
b = errorbar(rand(4),rand(4));
legend([a; b], {'a', 'b', 'c', 'd', 'a2', 'b2', 'c2', 'd2'});
How come and what to do about it?

Best Answer

Remove the semicolon in legend to errorbar.