我有两个来自其中任何一个的文件我将使用以下代码绘制一个点线:
set terminal postscript eps color solid font "Helvetica, 22"
set size ratio 0.625
set output "example.eps"
set key right top
plot "traffic.txt" using 1:2 title "traffic" with lp pt 7 ps 1 lc rgb "red", \
"solar.txt" using 1:($2*100) title "solar" with lp pt 9 ps 1 lc rgb "blue"
Run Code Online (Sandbox Code Playgroud)
两条线与x轴一起形成区域,并且由两条线形成的区域重叠.我想知道如何遮蔽重叠的部分.
谢谢!
(使用的文件如下)
档案1
1 66.660000
2 47.830000
3 39.270000
4 27.940000
5 24.990000
6 27.930000
7 32.060000
8 43.650000
9 70.470000
10 73.430000
11 87.690000
12 111.790000
13 122.170000
14 114.930000
15 111.620000
16 109.330000
17 121.370000
18 118.600000
19 132.890000
20 132.480000
21 148.360000
22 152.260000
23 140.510000
24 99.120000
Run Code Online (Sandbox Code Playgroud)
档案2
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0.121933
10 1.81455
11 2.25622
12 2.67994
13 2.87834
14 2.53149
15 1.29541
16 0.57571
17 0.0883007
18 0
19 0
20 0
21 0
22 0
23 0
24 0
Run Code Online (Sandbox Code Playgroud)
您可以使用filledcurves绘图样式.为此,所有数据必须包含在一个文件中.您可以即时组合文件,例如paste.对于具有python外观的平台无关解决方案,例如这个答案.
随着filledcurves你也可以区分above,并below以使用不同的颜色:
set key right top
set autoscale xfix
set xtics 4
plot "< paste traffic.txt solar.txt" using 1:2:($4*100) with filledcurves below lc rgb "#ffaaaa" t '', \
"" using 1:2:($4*100) with filledcurves above lc rgb "#aaaaff" t '',\
"traffic.txt" using 1:2 title "traffic" with lp pt 7 ps 1 lc rgb "red", \
"solar.txt" using 1:($2*100) title "solar" with lp pt 9 ps 1 lc rgb "blue"
Run Code Online (Sandbox Code Playgroud)
4.6.4的结果是:

要仅遮蔽两条曲线重叠的区域,您需要一个工作日.首先遮蔽较窄曲线和x1轴之间的区域,然后用白色覆盖该阴影的部分:
set autoscale xfix
set xtics 4
plot "< paste traffic.txt solar.txt" using 1:($4*100) with filledcurves x1 lc rgb "#ffaaaa" t '', \
"" using 1:2:($4*100) with filledcurves below lc rgb "white" t '',\
"traffic.txt" using 1:2 title "traffic" with lp pt 7 ps 1 lc rgb "red", \
"solar.txt" using 1:($2*100) title "solar" with lp pt 9 ps 1 lc rgb "blue"
Run Code Online (Sandbox Code Playgroud)
这给出了:
