假设你的倾斜度数据与每行一个值的文件,你可以将其转换为一个字符串,然后作为阵列使用。通过将EOL字符替换为空格来将数据转换为tr
实用程序。然后在功能f(k,x)
中使用范围[x1:x2]
中的每个值。
这里是数据文件:
$ cat rob.dat
20
10
5
2
-2
-5
-10
-20
它被转换成:20 10 5 2 -2 -5 -10 -20
和存储在变量a
。
同巴新的终端,就可以得到一张图片,但没有斜体符号:
set term pngcairo enh mono solid lw 1.5 font "Helvetica,14" size 600,800
set output "rob.png"
set nokey
set noborder
set noxtics
set noytics
x1=-0.1
x2=10.0
f(k,x)=(x>=x1 && x<=x2 ? k*x : 1/0)
a=system("tr '\\n' ' ' < rob.dat")
v(n)=word(a,n)
set style arrow 1 head size 0.2, 25 filled
set arrow from x1-1,0 to x2+1.,0 arrowstyle 1
set arrow from 0.,f(v(8),x2) to 0.,f(v(1),x2) arrowstyle 1
set arrow from 4.,100. to 7.,60. arrowstyle 1 front
set label "Selection interval\nfor {/:Italic q_{j+1} = k}" at 1.,120.
set label "{/:Italic U_a = r{/Symbol r}d}" at x2+0.1, f(v(1),x2)
set label "{/:Italic U_k}" at x2+0.1, f(v(2),x2)
set label "{/:Italic L_k}" at x2+0.1, f(v(3),x2)
set label "{/:Italic U_0}" at x2+0.1, f(v(4),x2)
set label "{/:Italic L_0}" at x2+0.1, f(v(5),x2)
set label "{/:Italic U_k}" at x2+0.1, f(v(6),x2)
set label "{/:Italic L_k}" at x2+0.1, f(v(7),x2)
set label "{/:Italic L_{-a} = -r{/Symbol r}d}" at x2+0.1, f(v(8),x2)
set label "{/Italic rw[j]}" at 0.3,f(v(1),x2)
set label "{/Italic k} < 0" at 2.,-130.
set style fill solid 0.3
plot [-2:12][] for [b in a] f(b,x) w l lw 2 lc rgb "black", "+" u 1:(f(v(2),$1)):(f(v(3),$1)) w filledcurves
![enter image description here](https://i.stack.imgur.com/s1KbE.png)
使用PostScript EPS终端,你可以得到的人(代替两个第一行):
set term post eps enh mono solid lw 2 font "Helvetica,30" size 6 in,9 in
set output "rob.eps"
![enter image description here](https://i.stack.imgur.com/D52t5.png)
嗨,我正在阅读你的回答呃,你用的是什么版本的gnuplot?我有4.0。不知道你的代码是否也适用于我。 – user8469759
我的版本是4.6。升级gnuplot,因为这是一个相当旧的版本。 –