我有一个包含一些命令的文件:
$ 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"
$
我不会在这里显示 reportGraph_# 的内容,但是任何包含 2 个点的内容都是有效的。
然后我用这个文件作为参数启动 gnuplot,我收到关于 Arial 的警告(我不完全确定为什么)。
$ gnuplot -e "output='footprint.png' " components.plg
Could not find/open font when opening font "arial", using internal non-scalable font
$
但是,结果图像的文本不是 Helvetica(但更多的是 Monospace sans)。
这是两个图像(第一个是命令行的输出,第二个是在 gnuplot shell 中启动的相同命令序列的输出,以及导出结果图像)。有一个区别,我没有在 gnuplot 中使用前两个命令(set terminal png
和 set output output
)——我只是将图像“导出”为 png。
问题是:为什么我在这两张图片中没有相同的字体? 我想要 Helvetica(或 Lucida Grande,但不是等宽字体)。
最佳答案
Gnuplot 有各种各样的终端。当您启动交互式 gnuplot session 并绘图时,您可能会使用 wxt
或 qt
终端。通过从绘图窗口导出图像,您可以将图像保存为这些终端创建的图像。
现在,使用 set terminal png
您使用一个不同的且非常旧的终端,具有不同的功能,尤其是在字体渲染方面。
如果您想将图像直接保存为 png,请使用 pngcairo
终端,生成更高质量的图像(结果应该等同于从 wxt
导出的图像)。
pngcairo
,或 pdfcairo
终端还应该正确处理您的字体。
关于linux - 使用命令行或 gnuplot 命令时,gnuplot 中的字体不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40912188/