为什么不使用标准的 octave-4.0.0 图形工具包解释下标?

Why are subscripts not interpreted with the standard octave-4.0.0 graphics toolkit?

我对 Octave 比较陌生,我在保存图形时遇到了问题,该图形由一组使用 "for" 循环生成的子图组成。

为了说明这个问题,我生成了本 post 底部显示的示例代码。在定义了自变量 (x) 和因变量 (y = 2*x) 之后,一个 for 循环从 i = 1:4 开始,每次使用 randn 函数生成一个随机数向量 (err)。在 for 循环的每一步中,都会生成一个子图,其中包含: (a) 原始数据 (y),以实线表示; (b) 随机数据 (y + i*err) 以彩色标记表示。

具有相应线条和标记的子图由 GNU Octave 界面正确生成,y 轴标签格式 ylabel('f(x) = y, f(x) = y_{rand}') 也根据需要显示字符串 "rand"作为子索引。

但是,当我尝试使用 "print" 或 "saveas" 函数为 pdf 或 eps 格式保存图形时,仅保留随机数据(彩色标记)并且 yaxis 标签是明确显示为:"f(x) = y. f(x) = y_{rand}",忽略格式。

作为参考,我在 Ubuntu 14.04 LTS 上 运行ning Octave 4.0.0,Linux OS 来自虚拟机 运行机器使用 Windows 8.1.

感谢您的关注。

维尼西奥

clf
clear all
clc

% Define the indepedent (x) and dependent (y) variables
x = 0:1:20;
y = 2*x;

% Allocate random error vector
err = zeros(1, length(x));
color = jet(4);

for i = 1:4

  % Generate random error vector with mean = zero, var = 1
  err = randn(1, length(x));

  subplot(2, 2, i)

    % Plot original data (y)
    plot(x, y, '-k', 'markersize', 9)
    hold on

    % Plot random data (y + err)
    plot(x, y + i.*err, 'ok', 'markerfacecolor', color(i, 1:end))
    hold on    

  % Edit plot
  set(gca, 'fontsize', 16)  
  ylabel('f(x) = y, f(x) = y_{rand}')
  xlabel('x')
  ylim([-10 50])
  hold all

end

% Set directory and save figure
cd ~/Documents/Octave;
saveas(gcf, "fig1.eps")

这个错误的行为可以在 4.0.0 中用这个更短的例子重现:

axes
ylabel("f(x) = y, f(x) = y_{rand}")

已在当前开发版本中修复,无需提交错误报告。

同时,作为解决方法,可以使用 graphics_toolkit("gnuplot")

请记得在测试前创建一个新的 figure,或 close all。事实上,以前的 graphics_toolkit 仍然用于现有数字。