Legend with Error Bars
조회 수: 34 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2019년 2월 21일
답변: MathWorks Support Team
2019년 3월 26일
I have a plot that includes several lines with error bars and a legend. I want the legend to only show the different lines, but when I create the legend it also includes a label for the error bars. How do I remove the error bars from the legend?
채택된 답변
MathWorks Support Team
2019년 2월 21일
If you add the "errorbar" after _y_ou add the “legend”, the “legend” will automatically update to include the new “errorbar” handle. There are two ways around this.
You can add the “errorbar” before you add the “legend”:
% code for Line_1 and Line_2
errorbar(x, y, y_lower, y_upper, '.')
legend({'Line_1','Line_2'}) % The legend will only annotate the two labels you provided
Alternatively, if you need to add the “errorbar” after you add the “legend”, you can set the “errorbar” handle to be invisible. This will prevent the “legend” from updating with the new “errorbar” handle:
% code for Line_1 and Line_2
legend({'Line_1','Line_2'})
errorbar(x, y, y_lower, y_upper, '.', 'HandleVisibility','off') % The errorbar handle is not visible, preventing the legend from updating
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!