필터 지우기
필터 지우기

Errorbar + multiple plots + one legend

조회 수: 2 (최근 30일)
Guido
Guido 2011년 11월 25일
댓글: Juan Guerrero 2021년 2월 12일
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?

채택된 답변

Grzegorz Knor
Grzegorz Knor 2011년 11월 25일
Remove the semicolon in legend to errorbar.

추가 답변 (2개)

Guido
Guido 2011년 11월 25일
Strange, but it works!
Thanks Grzegorz!

Sorcha Craven Heffernan
Sorcha Craven Heffernan 2017년 12월 13일
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
Juan Guerrero
Juan Guerrero 2021년 2월 12일
Maybe arguments 'x' and 'y' are the same for both graphs?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by