nschloe/matlab2tikz — Issue #59: Regression in moveToBoundingBox()
Author: burkart
Created: 2012-01-10 01:05:19+00:00
State: open

Commit dc267fa (increase the bounding box limits to +-164) introduced a regression in the function moveToBoundingBox(). When using this version or any of the ones thereafter the following code produces an error:

```
addpath('path/to/matlab2tikz/src')
x=1:199; % 1:99 => no error
y=rand(length(x), 1);
figure
plot(x, y, 'b+')
matlab2tikz('000.tikz', 'showInfo', false)
```

The error message in MATLAB is as follows:

```
??? Error using ==> matlab2tikz>moveToBoundingBox at 1583
Could not determine were the outside point sits with respect to the box. Both x and xRef outside the
box?

Error in ==> matlab2tikz>splitByOutliers at 1410
new = moveToBoundingBox( outData, ref, xLimLarger, yLimLarger );

Error in ==> matlab2tikz>splitLine at 1176
[xDataCell , yDataCell] = splitByOutliers( xDataCell, yDataCell, xLim, yLim );

Error in ==> matlab2tikz>drawLine at 1015
[xDataCell, yDataCell] = splitLine( m2t, xData, yData, xLim, yLim );

Error in ==> matlab2tikz>handleAllChildren at 420
[m2t, env] = drawLine( m2t, child );

Error in ==> matlab2tikz>drawAxes at 892
[ m2t, childrenEnvs ] = handleAllChildren( m2t, handle );

Error in ==> matlab2tikz>saveToFile at 335
m2t = drawAxes( m2t, visibleAxesHandles(ix(k)), alignmentOptions(ix(k)) );

Error in ==> matlab2tikz at 266
saveToFile( m2t, fid, fileWasOpen );
```

A similar error is reported when using Octave. Note that whether or not the error occurs depends on the size of ```x```. A vector from 1 to 99 did not produce an error in any of my experiments whereas a vector ranging from 1 to 199 always did. I didn't try to come up with the precise cut-off point.

The example code above does work when using the version from commit 6fc70d9 (the one before the regression was introduced).