Gnuplot, how to *skip* missing data files?

后端 未结 2 2007
悲哀的现实
悲哀的现实 2020-12-30 10:06

Depending on various factors i may not have 1 or more data files, referenced in pre-defined gnuplot plot instructions, that don\'t exist. When this is the case i get \"w

2条回答
  •  清歌不尽
    2020-12-30 10:13

    Here is a similar solution without a helper script

    file_exists(file) = system("[ -f '".file."' ] && echo '1' || echo '0'") + 0
    if ( file_exists("mydatafile") ) plot "mydatafile" u 1:2 ...
    

    the + 0 part is to convert the result from string to integer, in this way you can also use the negation

    if ( ! file_exists("mydatafile") ) print "mydatafile not found."
    

提交回复
热议问题