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');
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
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
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.
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://stackoverflow.com/questions/26925239/octave-windows-umlauts-in-plots-displayed-but-not-saved-as-image