When you specify errorbar linestyles, how do you port them into the legend?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(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!