保存文件时特殊字符中断

Special characters break when saving a file

在 运行 下面的程序中,Octave 显示一个带有图例 ä 的图形。然而,保存的 pdf 文件中的数字显示 ^/。对于 png 或 jpeg 等其他格式也是如此。任何想法如何解决这一问题?我确实搜索了一段时间,但不知何故未能找到解决方案。

我在 Ubuntu 14.04 上使用 4.2.1 版。

x = linspace(1,10)
y= sin(x)
plot(x,y)
legend('ä')
print('test.pdf')

编辑:
所以我确实找到了解决这个问题的可能方法:

print('test.pdf','dpdfcairo')  

这会产生以下错误:

error: print.m: PDFCAIRO output is not available for GL2PS output

搜索错误消息将我带到旧的 gnuplot 线程,我对如何解决这个问题有点迷茫。

您需要添加行

graphics_toolkit("gnuplot");

开头并使用 '-dpdfcairo' 而不是 'dpdfcairo'

我想 Octave 默认加载 qtfltk 图形工具包,但 gnuplot 仅支持使用 pdfcairo。来自 Octave documentation:

Generate Cairo based output when using the Gnuplot graphics toolkit.

所以完整的代码是:

graphics_toolkit("gnuplot");
x = linspace(1,10);
y= sin(x);
plot(x,y);
legend('ä');
print('test.pdf', '-dpdfcairo');