質問

I made a script as following to plot with GnuPlot.

#!/usr/bin/gnuplot
#file: myplot
set term svg;
set out 'figfile.svg';
plot './datafile.dat' with lp;
set term wxt 0;
set out;

So, I can create a figure file as

$./myplot

However, I have to edit the script to replace 'figfile.svg' and 'datafile.dat' manually. Can I modify this script and use the following format to create a figure file?

$./myplot datafile.dat figfile.svg

Thanks all.

役に立ちましたか?

解決

You could wrap your call to gnuplot with a shell script:

#!/bin/sh

gnuplot <<EOF
set term svg
set out '$1'
plot '$2' with lp
set term wxt 0
set out
EOF

The shell would substitute $1 and $2 in the script with the first and second command line parameters.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top