Errorbar + multiple plots + one legend

10 Ansichten (letzte 30 Tage)
Guido
Guido am 25 Nov. 2011
Kommentiert: Juan Guerrero am 12 Feb. 2021
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?

Akzeptierte Antwort

Grzegorz Knor
Grzegorz Knor am 25 Nov. 2011
Remove the semicolon in legend to errorbar.

Weitere Antworten (2)

Guido
Guido am 25 Nov. 2011
Strange, but it works!
Thanks Grzegorz!

Sorcha Craven Heffernan
Sorcha Craven Heffernan am 13 Dez. 2017
I am having a similar problem errorbar(x, y, yneg, ypos, xpos, xneg, 'kx-', 'MarkerSize',10); hold on errorbar(x, y, y1neg, y1pos, xpos, xneg, 'rx-', 'MarkerSize',10); legend('Increasing current', 'Decreasing Current') hold off
my code is only plotting the second line
  1 Kommentar
Juan Guerrero
Juan Guerrero am 12 Feb. 2021
Maybe arguments 'x' and 'y' are the same for both graphs?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Errorbars finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by