Code covered by the BSD License  

Highlights from
Update error bar widths automatically on figure resize

image thumbnail

Update error bar widths automatically on figure resize

by

 

11 Nov 2011 (Updated )

Add callback to the current axis to maintain a sensible error bar width on zooming.

updateErrorBars(h)
function updateErrorBars(h)
% Function that automatically updates error bar dimensions as a figure is
% zoomed.
%
% EXAMPLE:
% updateErrorBars()

if nargin < 1
    h = gca;
end

hh = handle(h);

prop(1) = findprop(hh,'XLim');
prop(2) = findprop(hh,'YLim');

setappdata(hh,'updateErrorBars',handle.listener(hh,prop,'PropertyPostSet',@updateErrorBars_Callback));
end

function updateErrorBars_Callback(obj, evt)

ch = findobj(evt.AffectedObject,'Type','hggroup');

for idx=1:numel(ch)
    errorbar_tick(ch(idx));
end

end

Contact us