Keeping Error Bars while Subplotting
6 次查看(过去 30 天)
显示 更早的评论
I've written the following code which takes plotted data and dumps it into a subplot. I want to annotate each of the subplots with an error bar and some text. However, when i go to draw the error bars, the actual figure gets erased! (Notice even the x & y labeling gets erased)

What am I doing wrong? Here's my code:
figs = [2 4 3 6];
for j=1:4
endX = 200;
newh = copyobj(allchild(get(figs(j),'CurrentAxes')),h(j));
ylim(h(j), [0 .5]); ylabel(h(j),'S');
xlim(h(j), [0 endX]); xlabel(h(j), 'Time (ms)');
dataObjs = findobj(h(j),'-property','YData');
pks = findpeaks(dataObjs.YData); trs = findpeaks(-1*dataObjs.YData)*-1; ampSS = pks(end) - trs(end);
bracket = errorbar(h(j),endX,trs(end) + ampSS/2, ampSS/2,'vertical','linewidth',1.5);
txt = text(h(j),endX,trs(end) - .02, strcat('Amp = ',num2str(ampSS)), 'horizontalalignment','center','verticalalignment','top','fontsize',8);
end
Note that commenting the line with "bracket = ..." results in the orginal plot with annotations. So its a problem with errorbar.
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Errorbars 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!