Producing Plots for Papers using Octave
Since I really like the SIMD-way of manipulating data in Octave, all my data processing/visualization is done in it. In order to obtain high quality plots (for conference papers), I generate all plots in PDF format. Unfortunately, the default way of saving plots in PDF has a few caveats, which make them hard to be used in a paper directly. Therefore, I am sharing my experience on how to save plots in PDF format that can be used in a conference paper easily. There are mainly two problems, plot dimension and embedding fonts.
The following two commands fit the paper to the plot instead of the default A4 size, which makes it hard to include in a paper due to the surrounding excessive blank space.
set(gcf, 'PaperPosition', [0 0 8 6]);
Conferences often require all fonts used to be embedded in the final submission.
octave uses Helvetica for plotting by default, but it’s usually not
available on Linux. One can use
pdffonts to check what fonts are used in a pdf and whether a certain font is embedded or not.
When a font is not embedded, and it’s missing on the platform it’s viewed, a substitute font will be used. On my box, “Nimbus Sans” is used.
name object ID substitute font substitute font file
Instead of relying on the substitution, I can change the default font to something that’s available on my box so that
all fonts in the pdf are embedded. One can set the default font as shown below, but in order for it to take effect, the
Cairo renderer must be used. IOW, use
-dpdfcairo instead of
-dpdf. Another good font is “FreeSans”.
set (0, "defaultaxesfontname", "NimbusSans")
Running it using the following command so that it does not require X.
$ xvfb-run -a octave -q --no-gui tmp.m
§Bonus: normalize the PDF
If the generated PDFs are checked into the repo (for archive/sharing purpose), it’s better to strip the meta data firstly. The following commands are inspired from https://gist.github.com/hubgit/6078384
exiftool -overwrite_original -all:all="" test.pdf &> /dev/null