Barweb in 2014b doesn't work any more

조회 수: 3 (최근 30일)
Rainer
Rainer 2014년 10월 16일
댓글: Oleg Komarov 2015년 1월 3일
One of my favorite community functions barweb not longer works with 2014b due to the change in the way figure handles are referenced. Are there any barweb users out there that managed to tweak the barweb.m file to make it work?
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2015년 1월 3일
Using bar() together with errorbar() is an option since R2012b.

댓글을 달려면 로그인하십시오.

채택된 답변

Robert Cumming
Robert Cumming 2014년 10월 17일
The problem with this function is that it is failing on getting the X position of each bar - so that the errorbar can be placed on the middle of the bar.
The error actually occurs on:
x=get(get(handles.bars(i),'children'), 'xdata');
In HG1 this line was getting the X position of the patch. The bar is no longer a patch so you need to get the x position another way.
If you update the if statement to the following:
% Plot erros
for i = 1:numbars
if ~verLessThan('matlab', '8.4') % HG2
x = handles.bars(i).XData + handles.bars(i).XOffset;
else
x =get(get(handles.bars(i),'children'), 'xdata');
x = mean(x([1 3],:));
end
handles.errors(i) = errorbar(x, barvalues(:,i), errors(:,i), 'k', 'linestyle', 'none', 'linewidth', 2);
ymax = max([ymax; barvalues(:,i)+errors(:,i)]);
end
It works for a "trivial" example. I didn't check for passing in anymore than 2 inputs.
  댓글 수: 3
Robert Cumming
Robert Cumming 2014년 10월 17일
XOffset is a hidden property which details the position of the bar relative to the XData.
You can use this FEX to inspect these other properties.
Rainer
Rainer 2014년 10월 17일
Thank you Robert.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2014년 10월 16일
It looks like there are a few things in the legend call that need to change. The legend is no longer an axes so that is no longer a valid check.
  댓글 수: 1
Rainer
Rainer 2014년 10월 17일
This is what i get.
---- >> barweb([3,3,3],[1,1,1])
Index exceeds matrix dimensions.
Error in barweb (line 153) x = mean(x([1 3],:));
----
The offending line is actually
handles.bars = bar(barvalues, width,'edgecolor','k', 'linewidth', 2);
(x is derived from handles.bars)
In 2014a, handles.bars would have been a double value but now it is a structure and for the life of me i can't find any field in the structure that corresponds to the old handles.bars value.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Errorbars에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by