2013-11-09 95 views
4

我有2個文件從它們中的我會使用以下代碼繪製點線之間的陰影區域:形成劇情用線條

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" 

要麼符合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 

文件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 
+0

無需在全部大寫喊標題。這已經是大膽而又大膽了。 – 2013-11-09 07:19:34

回答

5

可以使用filledcurves繪圖風格。爲此,所有數據必須包含在一個文件中。您可以將文件即時組合與paste。對於Python平臺無關的解決方案this answer

隨着filledcurves可以abovebelow之間爲了區分也使用不同的顏色:

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" 

與4.6.4結果是:

enter image description here

遮陽只有區域兩條曲線重疊的地方,你需要一個工作區。第一遮擋較窄的曲線與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" 

這給:

enter image description here

+0

這很酷!但我期望的是遮蔽重疊區域(與當前陰影區域相反)。有可能這樣做嗎? –

+0

@ZheWen是的,看我的編輯。 – Christoph