Generate eps plot with appropriate font size and line width in GNU Octave

Because eps terminal is different from the one for screen display, the font size and line width should all be adjusted as the following example:

clist = GenColorList();

h = 1;

figure(h);

clf(h); # This is mandatory.

## Set the axis position. Sometimes, the Y axis title may be outside the picture, therefore, the whole aixs should be shifted a little to the right.

set(gca, "position", [0.16000 0.11000 0.77500 0.81500]);

## Set the font size of the axis labels: the default font is too small for eps output

fontsize = 20;

## Set the linewidth of the axis

set(gca, "fontsize", fontsize, "linewidth", 1);

hold on;

## Line width set to 3, the default value is too small.

plot(t, mu_f_5k_A, "color", clist(1,:), "linestyle", "-", "linewidth", 3, "marker", "o");

## Print to eps file with font size set to 24. This font size used for eps output control.

print(h, strcat(f, ".eps"), "-depsc2", "-F:24");

## Convert eps to png using Ghostscript. Actually, this can be simplified by calling the script eps2png

system(["gs -dNOSAFER -r300 -dBATCH -sDEVICE=png16m -dNOPAUSE -dEPSCrop -sOutputFile=\"", f, ".png\" \"", f, ".eps\""]);

For the new Octave version on Linux, such as v3.6.2, the situation is different.

The default font adopted by GNU Octave is {}, which is so strange. Then, when a figure file is printed using the print function, the program will complain that it cannot find or open the font file. Therefore, the following should be added before any plotting. Note that, the font “Arial” is not supported on myDebian Wheezy, but “Helvetica” is.

set (0, "defaultaxesfontname", "Helvetica");

set (0, "defaultaxesfontsize", 12);

set (0, "defaulttextfontname", "Helvetica");

set (0, "defaulttextfontsize", 12) ;

In addition, Octave would complain that it cannot find the binary file for epstool and fig2dev. The former can be installed directly from apt-get, while the latter is contained in the transfig package.

Meanwhile, this version of Octave is different from traditional one for figure plotting. For example, in order to produce figures with appropriate axis and label text font sizes, previously we have to set the font size to be larger than 20 pt and enforce the font size to be 24 pt when calling the print function, i.e. -F:24. But now, such internal bug has been removed, we do not need to specify the font size any more.

 

Generate eps plot with appropriate font size and line width in GNU Octave,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。