Gnuplot,如何“跳过"丢失的数据文件? [英] Gnuplot, how to *skip* missing data files?

查看:46
本文介绍了Gnuplot,如何“跳过"丢失的数据文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

取决于各种因素,我可能没有1个或多个不存在的,在预定义的gnuplot绘图指令中引用的数据文件.在这种情况下,我会收到警告:跳过不可读的文件" ,这将取消其余的说明.

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 "warning: Skipping unreadable file" which cancels the rest of the instructions.

有什么方法可以让gnuplot跳过所有丢失的数据文件并绘制所有现有文件吗?

Is there any way i can ask gnuplot to skip any missing data files and plot all of the existing ones?

推荐答案

不幸的是,如果没有简单的帮助程序脚本,我似乎无法弄清楚该如何做.这是我使用助手"的解决方案:

Unfortunately, I can't seem to figure out how to do this without a simple helper script. Here's my solution with the "helper":

#!/bin/bash
#script ismissing.sh.  prints 1 if the file is missing, 0 if it exists.
test -e $1
echo $?

现在,使其可执行:

chmod +x ismissing.sh

现在,在您的gnuplot脚本中,您可以创建一个简单的函数:

Now in your gnuplot script, you can create a simple function:

is_missing(x)=system("/path/to/ismissing.sh ".x)

,然后按以下步骤保护绘图命令:

and then you guard your plot commands as follows:

if (! is_missing("mydatafile") ) plot "mydatafile" u 1:2 ...

编辑

似乎gnuplot不会因为文件丢失而阻塞-当gnuplot尝试根据丢失的数据设置绘图范围时,就会出现实际问题(我假设您正在自动缩放轴范围).另一种解决方案是显式设置轴范围:

It appears that gnuplot isn't choking because your file is missing -- The actual problem arises when gnuplot tries to set the range for the plot from the missing data (I assume you're autoscaling the axis ranges). Another solution is to explicitly set the axis ranges:

set xrange [-10:10]
set yrange [-1:1]
plot "does_not_exist" u 1:2
plot sin(x)  #still plots

这篇关于Gnuplot,如何“跳过"丢失的数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆