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!