Dar*_*lar 5 plot graph gnuplot
我有一个包含三列的数据文件:
1 1.0 1
2 1.5 2
3 0.0 3
4 1.2 2.5
5 1.0 1
6 1.1 5
Run Code Online (Sandbox Code Playgroud)
其中第一列是我的 X 值,第二列是我的 Y 值,第三列是线宽。我希望根据第三列线宽绘制每个线段。
我试过:
plot 'file1.dat' using 1:2:3 with lines lw var
Run Code Online (Sandbox Code Playgroud)
但我得到未定义的变量:var 错误。
这在 gnuplot 中可能吗?
谢谢。
如果将第 3 列定义为点 n 和 n+1 之间的线宽(因此该行第 3 列的值将被忽略),您可以作弊:
stat 'file1.dat'
n=STATS_records
plot for [i=0:0] 'file1.dat' using 1:2:(alma=$3) every ::i::i w l lc 1 lw 1
plot for [i=0:n-1] 'file1.dat' using 1:2:(alma=$3) every ::i::i+1 w l lc 1 lw alma notitle
Run Code Online (Sandbox Code Playgroud)
或者
plot 'file1.dat' u 0:1
n=GPVAL_DATA_X_MAX
plot for [i=0:0] 'file1.dat' using 1:2:(alma=$3) every ::i::i w l lc 1 lw 1
plot for [i=0:n] 'file1.dat' using 1:2:(alma=$3) every ::i::i+1 w l lc 1 lw alma notitle
Run Code Online (Sandbox Code Playgroud)
您需要首先plot for[i=0:0]“初始化”变量“alma”。