boundedline-pkg
boundedline-pkg copied to clipboard
Patches don't render properly if upper/lower (or left/right) bounds cross each other
If bounds are defined in such a way that the bounds cross over each other, the resulting patch is not rendered correctly. This can occur if, for example, the bounds are applied to the independent rather than the dependent variable in a line plot:
x = 1:1000;
y = sind(x);
e = 70;
boundedline(x,y,e,'orientation','horiz');

(Issue raised by Chad Greene via email)
A short-term workaround for this would be to divide the line into segments at each change in slope direction:
x = 1:1000;
y = sind(x);
e = 70;
idx = find(diff(sign(diff(y))) ~= 0);
se = [[1 idx+1]; [idx length(y)]];
for ii = 1:size(se,2)
[hl(ii), hp(ii)] = boundedline(x(se(1,ii):se(2,ii)), y(se(1,ii):se(2,ii)), e, 'orientation', 'horiz');
end
uistack(hl, 'top')

I'll add this workaround (in more robust form) to the code itself when I get a chance.