Skip to content

Commit 4467fa0

Browse files
committed
Octave also has new-style colorOrderIndex
Tests for `verLessThan('matlab', ...)` give an error on Octave. Use a helper function to check which platform we're on it. This particular "new graphics mode" was added around Octave 8, but but Chebfun only works on Octave >= 11 so no need for specific Octave version checks.
1 parent 0fd2832 commit 4467fa0

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

@chebfun/plot.m

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,16 @@
302302

303303
%% Plotting starts here:
304304

305+
% For plotting, it's useful to know whether we're running in old or new
306+
% Matlab graphics mode
307+
if ( is_octave() || ~verLessThan('matlab', '8.4') )
308+
newGraphicsMode = true;
309+
else
310+
newGraphicsMode = false;
311+
end
312+
305313
% Acquire initial color cycle if running R2014b+.
306-
if ( ~compatible_verLessThan('matlab', '8.4') )
314+
if ( newGraphicsMode )
307315
if ( ~holdState )
308316
set(gca, 'ColorOrderIndex', 1);
309317
end
@@ -318,7 +326,7 @@
318326
hold on
319327

320328
% Get color cycle prior to point plot if running R2014b.
321-
if ( ~compatible_verLessThan('matlab', '8.4') )
329+
if ( newGraphicsMode )
322330
newColorOrder = get(gca, 'ColorOrderIndex');
323331
set(gca, 'ColorOrderIndex', originalColorOrder)
324332
end
@@ -333,7 +341,7 @@
333341
end
334342

335343
% Reset color cycle prior to jump plot if running R2014b.
336-
if ( ~compatible_verLessThan('matlab', '8.4') )
344+
if ( newGraphicsMode )
337345
set(gca, 'ColorOrderIndex', originalColorOrder);
338346
end
339347

@@ -366,7 +374,7 @@
366374
end
367375

368376
% Reset colors prior to legend data plot if running R2014b.
369-
if ( ~compatible_verLessThan('matlab', '8.4') )
377+
if ( newGraphicsMode )
370378
set(gca, 'ColorOrderIndex', originalColorOrder);
371379
end
372380

@@ -387,7 +395,7 @@
387395
end
388396

389397
% Reset colors prior to legend data plot if running R2014b.
390-
if ( ~compatible_verLessThan('matlab', '8.4') )
398+
if ( newGraphicsMode )
391399
set(gca, 'ColorOrderIndex', newColorOrder);
392400
end
393401

@@ -445,15 +453,21 @@
445453
%PLOTDELTAS Plots delta functions.
446454
h = [];
447455

456+
if ( is_octave() || ~verLessThan('matlab', '8.4') )
457+
newGraphicsMode = true;
458+
else
459+
newGraphicsMode = false;
460+
end
461+
448462
% Get and save the current ColorOrder if running on R2014a or earlier.
449-
if ( compatible_verLessThan('matlab', '8.4') )
463+
if ( ~newGraphicsMode )
450464
originalColorOrder = get(gca, 'ColorOrder');
451465
colorOrder = circshift(originalColorOrder, 1);
452466
end
453467

454468
for k = 1:1:numel(deltaData)
455469
% Set color for the next delta function plot.
456-
if ( compatible_verLessThan('matlab', '8.4') )
470+
if ( ~newGraphicsMode )
457471
% Manually manipulate the ColorOrder for R2014a or earlier.
458472
colorOrder = circshift(colorOrder, -1);
459473
set(gca, 'ColorOrder', colorOrder);
@@ -466,7 +480,7 @@
466480
end
467481

468482
% Restore the ColorOrder if running on R2014a or earlier.
469-
if ( compatible_verLessThan('matlab', '8.4') )
483+
if ( ~newGraphicsMode )
470484
set(gca, 'ColorOrder', originalColorOrder);
471485
end
472486
end

@separableApprox/waterfall.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
% For plotting, it's useful to know whether we're running in old or new
3939
% Matlab graphics mode
40-
if ( ~verLessThan('matlab', '8.4') )
40+
if ( is_octave() || ~verLessThan('matlab', '8.4') )
4141
newMatlabVersion = true;
4242
else
4343
newMatlabVersion = false;

0 commit comments

Comments
 (0)