【问题标题】:Shading command produces different results in MATLAB and Octave着色命令在 MATLAB 和 Octave 中产生不同的结果
【发布时间】:2020-05-28 02:05:31
【问题描述】:

shading facetedshading interp 命令在 MATLAB 和 Octave 中产生不同的图形。

考虑这段代码:

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

这是 MATLAB 中的结果:

以及 Octave 生成​​的结果:

MATLAB 生成一个正确的图形。这个 Octave 图形有什么问题?

我们得到两个不同输出的原因是什么? view 命令有问题吗?

编辑(错误报告后)

已为 Ocatve 6.1 修复:https://hg.savannah.gnu.org/hgweb/octave/raw-file/11072ea6a16c/scripts/plot/appearance/view.m

【问题讨论】:

  • 请注意,八度音程中的最后 2 个图将 y 轴倒置。我怀疑这有很大的不同。也许八度音程也会以某种方式置换输入
  • 与@Ander 的评论一致:Octave 中的view([0, 0, -1]) 似乎产生了与 MATLAB 版本相当的输出。
  • @HansHirse view([0, 0, -1]) 不会产生相同的结果。
  • @sci9 我又看了一遍,你是对的!完全不设置view 表明情节本身具有可比性,因此view 问题可能需要以不同方式解决……不过,安德的评论仍然有效。
  • y轴倒置了,还是xy轴互换了?再看颜色排列。我打了一个 xlabel('X axis') 电话来澄清这一点,看起来在 Octave 中,X 轴最终位于垂直轴而不是水平轴上。

标签: matlab plot graphics gnuplot octave


【解决方案1】:

您的代码看起来不错。我可以在 macOS 上重现 Octave 4.4 和 5.2。

拨打xlabel('X Axis'); 电话以澄清发生了什么。

这看起来确实像是 Octave 的 view 实现中的一个错误。 X 轴和 Y 轴似乎正在交换。您能否在 https://savannah.gnu.org/bugs/?group=octave 的 Octave 问题跟踪器上将此报告为错误?

【讨论】:

  • 那么ylabel('Y axis') 呢?我在图中没有看到此调用的输出!
  • 请参阅错误 #57800:savannah.gnu.org/bugs/index.php?57800
  • Ocatve 6.1 已修复此问题。
  • 万岁!当某些事情得到及时修复时,总是很高兴。感谢您的报告。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-09
  • 1970-01-01
  • 2017-06-24
  • 1970-01-01
  • 2015-04-24
  • 1970-01-01
相关资源
最近更新 更多