Octave/Windows: umlauts in plots displayed but not saved as image

僤鯓⒐⒋嵵緔 提交于 2019-12-02 02:23:35

问题


I use octave 3.8.2 (with gnuplot) under Windows. I want to write "special character" in the axis labels of plots. The umlaut 'ä' and special character µ are displayed in the figure but not saved to the image file using print. Partly, I can use the TeX command: '\mu' instead of 'µ' but for umlauts '\"a' instead of 'ä' does not work.

plot(1:10);
%set (findall (gcf (), "-property", "interpreter"), "interpreter", "TeX") % does not work
xlabel('Länge in µm');
ylabel('Breite in \mum');
print('umlaute.jpg', '-djpeg');

回答1:


graphics_toolkit("gnuplot") and pngcairo or pdfcairo produce a better output.

graphics_toolkit("gnuplot")
plot(1:10)
xlabel('Länge in µm')
ylabel('Breite in \mum')
print('umlaute.png', '-dpngcairo') # or
# print('umlaute.pdf', '-dpdfcairo')

With octave 3.8.2 under linux, the ouput is




回答2:


Using Octave 4.4.0 on Windows the bug seems to be fixed as least for graphics_toolkits gnuplot and qt with the print option '-dpngcairo'. So this script gives me a fine output in the file umlaute4-cairo.png .

% graphics_toolkit("gnuplot")
graphics_toolkit("qt")

% Do a simple plot with a German umlaut and a Greek micron signs
plot(1:10);
ylabel('Breite in \mum')
xlabel('Länge in \mum')

print('umlaute4.jpg', '-djpg') # not OK, bad umlauts
print('umlaute4.png', '-dpng') # not OK, bad umlauts
print('umlaute4-cairo.png', '-dpngcairo') # OK with gnuplot and qt



回答3:


Using Octave 5.1 on Windows with the qt graphics toolkit and latin1-coding it does now finally work!

graphics_toolkit("qt");
x=1:10;
plot(x, x);

title('Ä Ö Ü');
xlabel('H_2 in µm');
ylabel('Percent in %');
[![enter image description here][1]][1]print("test_umlaute.png");

Other combiations like UTF8 and and other graphics toolkit do not work.




回答4:


There is a problem in Octave 5.1 that the selected encoding for .m files is not restored on startup. You can either change the encoding in the settings and call "clear functions" to trigger the .m files being parsed again. Or you could call the internal function "mfile_encoding". For UTF-8 encoding that would be:

__mfile_encoding__ ("utf-8");
clear functions

https://savannah.gnu.org/bugs/?56782



来源:https://stackoverflow.com/questions/26925239/octave-windows-umlauts-in-plots-displayed-but-not-saved-as-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!