如何在gnuplot命令行设置xrange

问题描述 投票:0回答:1

我有好几个gnuplot脚本为我画图,我需要在命令行为每个gnuplot脚本设置相同的xrange值。我需要在命令行为每个gnuplot脚本设置相同的xrange值,我不想分别打开每个脚本。

gnuplot脚本(name:tlakD.gnuplot)中的代码。

set xdata time 
set timefmt "%m/%d/%Y %H:%M" # specify time string format
set xrange datum
set format x "%d/%m/%Y "

命令行尝试。gnuplot -e "datum='["1/1/19 12:00":"1/5/19 11:59"]'" tlakD.gnuplot

第二次尝试:我删除了xrange。

gnuplot脚本(name:tlakD.gnuplot)中的代码:命令行尝试:第二次尝试:我删除了xrange。

set xdata time 
set timefmt "%m/%d/%Y %H:%M" # specify time string format
set format x "%d/%m/%Y "

命令行尝试:gnuplot -e "xrange='["1/1/19 12:00":"1/5/19 11:59"]'" tlakD.gnuplot

我想知道我想要什么gnuplot -e "xrange='["1/1/19 12:00":"1/5/19 11:59"]'" tlakD.gnuplot ; vlhkosD.gnuplot; teplotaD.gnuplo and many more gnuplots scripts我想用相同的xrange运行所有的脚本,谢谢。

command-line set gnuplot default-value xrange
1个回答
0
投票

似乎你不能指定一个范围。[...:...] 在一个变量中,但你可以在2个单独的字符串变量中进行。

gnuplot  -e a='"1/1/19 12:00"' -e b='"1/5/19 11:59]"'

set xrange [a:b]

1
投票

我建议把范围命令放在一个单独的文件中 然后在命令中同时调用范围文件和绘图文件。 你甚至可以有一个范围文件的集合,在绘图时选择你想要的那个文件。

 gnuplot setrange_1.gp tlakD.gp

它不需要使用 -e gnuplot将按照命令行上列出的每个文件的顺序执行,就像它们在执行前已经被连接成一个更大的文件一样。


0
投票

我创建了一个 data.txt 像这样的文件。

"2/1/2019 10:00:00" 4
"3/1/2019 10:00:00" 8
"4/1/2019 10:00:00" 16
"5/1/2019 10:00:00" 32

我要在里面执行的命令是 gnuplot 会是。

set timefmt '"%d/%m/%Y %H:%M:%S"'
set xdata time
set xrange ['"1/1/2019 12:00"':'"1/5/2019 11:59"']
plot "data.txt" using 1:2

所以,这意味着我的 bash 命令行将是:

gnuplot -p \
        -e "set timefmt '\"%d/%m/%Y %H:%M:%S\"'"                    \
        -e "set xdata time"                                         \
        -e "set xrange ['\"1/1/2019 12:00\"':'\"5/1/2019 11:59\"']" \
        -e "plot \"data.txt\" using 1:2"

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.