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.
§Plot Dimension
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.
1 | set(gcf, 'PaperPosition', [0 0 8 6]); |
§Embedding Fonts
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.
1 | pdffonts test.pdf |
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.
1 | pdffonts -subst test.pdf |
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”.
1 | set (0, "defaultaxesfontname", "NimbusSans") |
§Complete program
1 | graphics_toolkit('gnuplot'); |
Running it using the following command so that it does not require X.
1 | $ 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
1 | exiftool -overwrite_original -all:all="" test.pdf &> /dev/null |