我在用此 FEX 条目 http://www.mathworks.com/matlabcentral/fileexchange/27485-boundedline-line-plots-with-shaded-errorconfidence-intervals绘制 X 轴上绘制的变量的水平阴影误差线。该变量绘制在不同的区域/区域中,因此,3 个区域有 3 个阴影误差线。我想将误差线的图例(阴影区域)以及任何区域的平均值(实线)组合成一个图例,由与该区域颜色相同的实线(或补丁内的实线)表示。
我的代码的绘图方式:我绘制的方式的综合示例如下所示
fh = figure();
axesh = axes('Parent', fh);
nZones = 4;
nPts = 10;
X = nan*ones(nPts, nZones);
Y = nan*ones(nPts, nZones);
XError = nan*ones(10, 4);
clr = {'r', 'b', 'g', 'm', 'y', 'c'};
for iZone = 1:nZones
X(:, iZone) = randi(10, nPts, 1);
Y(:, iZone) = randi(10, nPts, 1);
XError(:, iZone) = rand(nPts, 1);
% Append Legend Entries/Tags
if iZone == 1
TagAx = {['Zone # ', num2str(iZone)]};
else
TagAx = [TagAx, {['Zone # ', num2str(iZone)]}];
end
hold(axesh, 'on')
[hLine, hPatch] = boundedline(X(:, iZone), Y(:, iZone), XError(:, iZone),...
strcat('-', clr{iZone}), axesh, 'transparency', 0.15,...
'orientation', 'horiz');
legend(TagAx);
xlabel(axesh, 'X', 'Fontweight', 'Bold');
ylabel(axesh, 'Y', 'Fontweight', 'Bold');
title(axesh, 'Error bars in X', 'Fontweight', 'Bold');
end
传奇人物目前的表现方式:
我已经尝试过:正如有人在评论区 http://www.mathworks.com/matlabcentral/fileexchange/27485-boundedline-line-plots-with-shaded-errorconfidence-intervals该文件的 FEX 页面的第 314 行后添加以下代码有界线代码 http://www.mathworks.com/matlabcentral/fileexchange/27485-boundedline-line-plots-with-shaded-errorconfidence-intervals/content/boundedline.m.
set(get(get(hp(iln),'Annotation'),'LegendInformation'),'IconDisplayStyle','off');
但是,这样做时我收到此错误:
名称“Annotation”不是以下实例的可访问属性
类“根”。
EDIT:前两个答案建议访问补丁和行的图例句柄,这些句柄由函数作为输出返回boundedline
。我尝试过,但问题仍然没有解决,因为图例条目仍然与区域不一致。