boundedline-pkg icon indicating copy to clipboard operation
boundedline-pkg copied to clipboard

Patches don't render properly if upper/lower (or left/right) bounds cross each other

Open kakearney opened this issue 8 years ago • 1 comments

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');

blcrisscross1

(Issue raised by Chad Greene via email)

kakearney avatar Mar 31 '17 21:03 kakearney

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')

blcrisscross2

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

kakearney avatar Mar 31 '17 21:03 kakearney