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
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 CenterFile Exchange에서 Errorbars에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by