在gnuplot图文件中使用相对路径 [英] Using relative paths in gnuplot plot files

查看:271
本文介绍了在gnuplot图文件中使用相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在gnuplot指令文件中,是否可以指示数据源文件和输出的相对路径?这些路径必须相对于gnuplot指令文件路径.

In a gnuplot instruction file, is it possible to indicate relative paths for the data source files and for the output? The paths must be relative to the gnuplot instruction file path.

上下文 我有很大的数据文件,其中包含12至50个x-y曲线,我使用PHP脚本和gnuplot处理这些曲线,以便提供数据的漂亮图形视图.这些视图是使用gnuplot生成的,对于每个视图,我都有一个.csv文件,一个gnuplot绘图指令文件和一个图形.

Context I have large data files containing between 12 to 50 x-y curves that I process using PHP scripts and gnuplot in order to provide nice graphic views of the data. The views are generated using gnuplot and for each view, I have one .csv file, one gnuplot plotting instruction file and one graphic.

所有内容都很好地分类到了文件夹中.通常,在文件夹中,图形位于顶层,然后在源/子文件夹中是.csv和gnuplot文件.

Everything is nicely sorted into folders. Usually, in a folder, the graphics are at the top level, then in a source/subfolder are the .csv and gnuplot files.

有时,我需要稍微更改图形.因此,我编辑了gnuplot文件,并通过直接调用gnuplot再次对其进行了绘制.一切都很好,直到我将文件夹移动到其他位置.我经常这样做.

Sometimes, I need to slightly change the graphic. So I edit the gnuplot file, and I plot it again by calling gnuplot directly. Everything is fine, until I move the folders elsewhere. Which I do frequently.

推荐答案

是的,您可以在gnuplot文件中指定相对路径:

Yes, you can specify relative paths in the gnuplot file:

set output '../path/to/outputs/output.eps'
plot '../path/to/csv/input.csv'

正常工作.如果要将路径指定为脚本的参数,建议使用bash包装器:

works fine. If you want to specify paths as arguments to the script, I recommend a bash wrapper:

#!/bin/bash

# argument 1 is path to input
# argument 2 is path to output

gnuplot << EOF
set terminal ...
set output '$2/output'

plot '$1/input1.csv', \
     '$1/input2.csv' ...
EOF

这篇关于在gnuplot图文件中使用相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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