Reputation: 776
The commands shading faceted
and shading interp
produce different figures in MATLAB and Octave.
Consider this code:
[X, Y] = meshgrid(0:2, 0:2);
Z = magic(3);
figure;
colormap('jet');
subplot(1, 3 ,1);
imagesc(Z);
axis xy
yticklabels({'0', '1', '2'})
yticks(1:3)
xticklabels({'0', '1', '2'})
xticks(1:3)
title('imagesc(Z)');
subplot(1,3,2);
surf(X, Y, Z);
shading faceted;
view([0,0,1]);
yticks(0:3)
xticks(0:3)
title('surf(X, Y, Z); shading faceted;');
subplot(1,3,3);
surf(X, Y, Z);
shading interp;
view([0,0,1]);
yticks(0:3)
xticks(0:3)
title('surf(X, Y, Z); shading interp;');
And the result generated by Octave:
MATLAB generates a correct figure.What is wrong with this Octave figure?
What is the reason we get two different outputs? Is it an issue with to the view
command?
It's been fixed for Ocatve 6.1: https://hg.savannah.gnu.org/hgweb/octave/raw-file/11072ea6a16c/scripts/plot/appearance/view.m
Upvotes: 4
Views: 386
Reputation: 23848
Your code looks right. I can reproduce in Octave 4.4 and 5.2 on macOS.
Throw in an xlabel('X Axis');
call to clarify what's going on.
This sure looks like a bug in Octave's implementation of view
. It appears the X and Y axes are getting swapped. Could you report this as a bug on the Octave issue tracker at https://savannah.gnu.org/bugs/?group=octave?
Upvotes: 1