bold enhanced text in gnuplot

andyras picture andyras · May 7, 2013 · Viewed 33.8k times · Source

UPDATE: this issue has been resolved in newer versions (>5.0) of gnuplot; see @andyras' answer.


I am having difficulty getting gnuplot to create labels with bold and enhanced text in non-postscript terminals. The following script

#!/usr/bin/env gnuplot

reset

set terminal pdfcairo enhanced color lw 3 size 3,2 font 'Arial-Bold'
set output 'output.pdf'

set tics scale 0

plot -x title 'normal text', \
-2*x t 'enhanced_{text}', \
-3*x t '{/Arial-Bold attempt to specify_{font}}'

set terminal pngcairo enhanced color lw 3 size 400,300 font 'Arial-Bold'
set output 'output.png'
replot

set terminal postscript enhanced color lw 3 size 6,4 font 'Arial-Bold'
set output 'output.eps'
replot

reset

Produces the following eps (converted to png with convert output.eps -rotate 90 outputeps.png):

enter image description here

which is fine. However, when I use the pdf or png terminals the result looks like this:

enter image description here

Note that while all the label text should be bold, only the label without any enhanced text is bold. In addition, when I try to manually specify the font (last line title) the font is different (reverts to the default?).

Is this behavior I should expect when not using the postscript terminal? Is there another way to specify fonts (i.e. is the naming scheme different outside of postscript)?

Answer

andyras picture andyras · Dec 21, 2015

Since version 5.0, gnuplot has a new syntax to handle this issue:

 "normal text {/Times:Bold boldface-newfont} {/:Italic slanted-default-font } back to normal text"]

These brackets can also be nested.