fzd fzd -4 years ago 104
Bash Question

Not the same font in gnuplot when using command line or gnuplot commands

I have a file containing some commands :

$ cat components.plg
set terminal png
set output output
set font "Helvetica,10"
unset xtics
unset ytics
unset border
plot "reportGraph_0" with lines title "Component 0", "reportGraph_1" with lines title "Component 1", "aoi.txt" with lines title "Area of interest"
$


I won't display the contents of reportGraph_# here, but anything with 2 points in them is valid.

I then launch gnuplot with this file as parameter, and I get a warning about Arial (I'm not entirely sure why).

$ gnuplot -e "output='footprint.png' " components.plg
Could not find/open font when opening font "arial", using internal non-scalable font
$


However, the result image has its text in non-Helvetica (but more in something like Monospace sans).

Here are the two images (first the output of the command line, second the output of the same sequence of commands launched in a gnuplot shell, and exporting the result image). There is one difference, I didn't use the first two commands (
set terminal png
and
set output output
) in gnuplot - I merely "exported" the image as png.
image from shell command line
image from gnuplot commands

The question is : why don't I have the same font in these two images?
I would like to have Helvetica (or Lucida Grande, but not a monospace font).

Answer Source

Gnuplot has a large variety of terminals. When you launch an interactive gnuplot session and plot you probably use the wxt or qt terminal. By exporting the image from the plot window you save the image as theyes were created by those terminals.

Now, with set terminal png you use a different and quite old terminal, with different capabilities, especially regarding font rendering.

If you want to save your image directly as png, use the pngcairoterminal, which produces higher quality images (the result should be equivalent to that of the exported image from wxt).

The pngcairo, or the pdfcairo terminals should also handle your fonts properly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download