gnuplot: Greek Letters in Labels Using PNG
User “quantamm” asks for help with gnuplot on the openSUSE forum. I actually tried to register there in order to answer the question, but the site, run by the Novell corporation, is seriously broken and I get nothing but redirect loops and database errors. So I’ll answer here, and hope that “quantamm” knows how to use Google and feed readers. Therefore this page becomes another entry in my campaign to replace buggy web fora with the open web.
The problem arises in attempting to use a Greek letter in a label using the
PNG terminal. It stopped working after an operating system upgrade. The user is trying to insert the letter using the “enhanced” font handling (
set term png enhanced) codes; the problem is in the system font configuration, rather than with gnuplot per se.
There are two types of solutions to this problem. Using the “enhanced” business does not lead to good output in general, but can be acceptable for inserting a single character. It’s better to adopt a workflow that will produce more attractive output, will be more likely to actually produce the characters you want, and be less likely to suddenly fail when you change your system’s font configuration.
In the current case, where the user simply wants to insert a single Greek letter, the quickest path to success will be to use a terminal that supports Unicode. This assumes a gnuplot version as recent as 4.3 or so. Typing
set term will yield a list of terminals available to gnuplot; if one of them happens to be
pngcairo, that will work. If that’s not installed, look for
After selecting a Unicode-capable terminal, you need merely use the usual
set label commands, typing the desired label directly at the prompt. Of course, you need some way to input Unicode characters; if your terminal program does not offer a direct method, you can, for example, construct your label in the vim editor using its digraph system, and copy-paste the result into the gnuplot session.
The above method will solve the problem of inserting isolated Greek or other special characters. The general solution to the problem of fancy labels (equations, etc.) is to take advantage of gnuplot’s many ways to interact with LaTeX. I have many examples of how to do this in my gnuplot book.