フィルターのクリア

When you specify errorbar linestyles, how do you port them into the legend?

2 ビュー (過去 30 日間)
Daniel
Daniel 2020 年 9 月 23 日
コメント済み: Daniel 2020 年 10 月 19 日
I found a great explanation of how to force a LineStyle change in the errorbars of an errorbar plot, but I've hit a corollary snag in my R2019a environment: when I call legend in my plot using that workaround, the colours and errorbar shapes are ported - but the linestyles I've used the link technique to edit in are not. How can I make the legend reflect my modified errorbars?
h1 = errorbar(1,1,0.3,0.2,'or');
xlim([0 5])
ylim([0 3])
h1.Bar.LineStyle = 'dashdot'
hold on
h2 = errorbar(3,1.4,0.1,0.4,'ok');
h2.Bar.LineStyle = 'dotted'
hold off
hl = legend('VarName1','VarName2');
legend boxoff
title(hl,'LegendTitle')
Note that the figure the code above generates shows different linestyles for the confidence intervals, but that these are not reflected in the legend, which shows solid lines where 'dashdot' or 'dotted' should be used.
I will also note that I can hack in appropriate lines and markers (albeit horiztonal instead of vertical, like the errorbar tokens) by the usual workaround of hold on; plot(desired style but outside desired window) ... ; actual errorbar calls ; hold off. But doing it this way loses the errorbar tokens, which I wanted to keep (assuming the linestyles showed well enough in the vertical space allotted).
  6 件のコメント
Adam Danz
Adam Danz 2020 年 10 月 17 日
Thanks for the updates, Daniel.
Daniel
Daniel 2020 年 10 月 19 日
No problem, Adam. I figure it's far better to be open about the likelihood of a solution here than to leave it otherwise abandoned. That gets my goat when I see it on other questions...
To the community at large: feel free to link to this query if you need an example of an OP proactively responding and keeping the community informed (and incidentally, providing background info + link and a MWE in the post) for someone else.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeErrorbars についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by