我对Octave相对较新,我在保存数字方面遇到了麻烦,包括一组用“for”循环生成的子图。
为了说明这个问题,我已经生成了本文底部显示的示例代码。在定义独立(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”,显示为子索引。
但是,当我尝试使用pdf或eps格式的“print”或“saveas”函数保存图形时,只保留随机数据(彩色标记),yaxis标签显式显示为:“f (x)= y。f(x)= y_ {rand}“,忽略格式化。
作为参考,我在Ubuntu 14.04 LTS上运行Octave 4.0.0,Linux操作系统使用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")
答案 0 :(得分:1)
使用这个较短的例子可以在4.0.0中重现这种错误的行为:
axes
ylabel("f(x) = y, f(x) = y_{rand}")
它已在当前开发版本中修复,因此无需提交错误报告。
同时,作为一种解决方法,可以使用graphics_toolkit("gnuplot")
。
请务必在测试前创建新的figure
或close all
。实际上,之前的graphics_toolkit
仍用于现有数据。