我想在pngcairo终端可用的时候将终端设置为pngcairo而不是png,我不想手动检查它的可用性并且每次都更新我的脚本.
当pngcairo终端不可用时,我的脚本中出现以下错误:
set terminal pngcairo
^
"./script.gnuplot", line 7: unknown or ambiguous terminal type; type just 'set terminal' for a list
Run Code Online (Sandbox Code Playgroud)
如何在我的gnuplot脚本中测试pngcairo的可用性,以便在不存在时将终端设置为png?
所有可用的终端都可通过变量获得GPVAL_TERMINALS,请参阅show variables all.使用该strstrt功能,您可以检查是否pngcairo可用:
if (strstrt(GPVAL_TERMINALS, 'pngcairo') > 0) {
set terminal pngcairo
} else {
set terminal png
}
Run Code Online (Sandbox Code Playgroud)