gpt4 book ai didi

linux - 为什么我的命令对 gnuplot 不起作用?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:48:36 25 4
gpt4 key购买 nike

我有包含

的输入文件 test.dat
1 1
2 2
3 3
4 4

我为 gnuplot 编写了脚本:

gnuplot <<EOF
set term png size 1000,1000;
set output "out.png";
set arrow from graph 0,1 to graph 0,1.1 filled
set arrow from graph 1,0 to graph 1.1,0 filled
set tmargin 5
set rmargin 20
set border 3
set tics nomirror
set grid
set xtics font "Verdana,14"
set ytics font "Verdana,14"
set nokey
set style line 1 lt 1 lw 3 pt 3 linecolor rgb "black"
set ylabel "Efficiency, %" offset 2,0,0 font "Verdana,14"
set xlabel "Cores, N" offset 0,0,0 font "Verdana,14"
func1(x) = x / 2
func2(x) = x * 2
plot "test.dat" u (func1($1)):(func2($2)) ls 1 smooth csplines;
EOF

但是当您尝试启动它时出现错误:

gnuplot> plot "test.dat" u (func1()):(func2()) ls 1 smooth csplines;
line 0: invalid expression

最佳答案

美元符号被解释为开始一个 shell 变量。使用 column 代替:

gnuplot <<EOF
set term png size 1000,1000;
set output "out.png";
func1(x) = x / 2
func2(x) = x * 2
plot "test.dat" u (func1(column(1))):(func2(column(2))) ls 1 smooth csplines;
EOF

关于linux - 为什么我的命令对 gnuplot 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38342625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com