2017-09-01 148 views
1

我有一個按升序排列的105個值的列表。我分那個名單5個子如圖所示如下表:使用gnuplot繪製每個子序列的不同顏色

id Seq1 Seq2 Seq3 Seq4 Seq5 
1 696.99 958.79 989.02 1018.28 1078.3 
2 869.21 959.26 989.02 1018.28 1078.3 
3 898.73 959.44 989.02 1018.28 1078.55 
4 898.73 959.44 989.02 1018.28 1078.55 
5 898.73 959.44 989.21 1018.28 1078.55 
6 898.73 959.44 989.21 1018.28 1078.55 
7 898.73 959.44 989.21 1018.28 1078.55 
8 898.79 959.44 989.21 1018.52 1078.69 
9 898.79 959.51 989.21 1018.52 1078.69 
10 898.79 959.51 989.21 1018.52 1078.69 
11 899.27 988.52 989.26 1018.52 1078.69 
12 899.27 988.65 989.26 1018.52 1078.69 
13 899.27 988.65 989.26 1018.52 1078.69 
14 899.44 988.65 989.26 1019.0 1078.73 
15 928.65 988.65 989.51 1019.0 1078.73 
16 928.73 989.0 989.51 1019.26 1078.73 
17 929.26 989.0 989.51 1078.3 1078.73 
18 958.73 989.0 989.51 1078.3 1078.73 
19 958.79 989.02 989.51 1078.3 1078.73 
29 958.79 989.02 1013.0 1078.3 1144.2 
21 958.79 989.02 1013.0 1078.3 1144.21 

我的問題是如何繪製所有連續 方式5個子又各具不同的顏色。我使用了以下腳本。但是 問題是它正在分開繪製它們,如下圖 所示。

enter image description here

#!/bin/bash 

#set key outside 
unset key 

set title "5 sequences des prix triés pour 120 jours avant la date de départ" 

set xlabel "séquences" 
set ylabel "Prix" 


# set xlabel "Jour de recherche avant la date de départ" 
# set ylabel "Nombre de dates de baisses pour chaque jour de recherche" 

set xtics font ", 11" 

set datafile separator "," 
# set autoscale 
set terminal pngcairo dashed 
set output 'sequence.png' 
set key autotitle columnhead 


plot "test.csv" every 4 u 2:xticlabels(1) w l lw 2 lc 1 ,\ 
     "test.csv" every 4 u 3:xticlabels(1) w l lw 2 lc 2 ,\ 
     "test.csv" every 4 u 4:xticlabels(1) w l lw 2 lc 3,\ 
     "test.csv" every 4 u 5:xticlabels(1) w l lw 2 lc 4,\ 
     "test.csv" every 4 u 5:xticlabels(1) w l lw 2 lc 5 

回答

2
plot for [IDX=0:4] 'prix.txt' u ($1 + IDX*21):(column(IDX+2)) title columnhead(IDX+2) w lp 

enter image description here

2

從這answer我改變您的數據僅僅是兩列:

1 696.99 
2 869.21 
3 898.73 
4 898.73 
5 898.73 
6 898.73 
7 898.73 
8 898.79 
9 898.79 
10 898.79 
11 899.27 
12 899.27 
13 899.27 
14 899.44 
15 928.65 
16 928.73 
17 929.26 
18 958.73 
19 958.79 
20 958.79 
21 958.79 


22 958.79 
23 959.26 
24 959.44 
25 959.44 
26 959.44 
27 959.44 
28 959.44 
29 959.44 
30 959.51 
31 959.51 
32 988.52 
33 988.65 
34 988.65 
35 988.65 
36 988.65 
37 989 
38 989 
39 989 
40 989.02 
41 989.02 
42 989.02 


43 989.02 
44 989.02 
45 989.02 
46 989.02 
47 989.21 
48 989.21 
49 989.21 
50 989.21 
51 989.21 
52 989.21 
53 989.26 
54 989.26 
55 989.26 
56 989.26 
57 989.51 
58 989.51 
59 989.51 
60 989.51 
61 989.51 
62 1013 
63 1013 


64 1018.28 
65 1018.28 
66 1018.28 
67 1018.28 
68 1018.28 
69 1018.28 
70 1018.28 
71 1018.52 
72 1018.52 
73 1018.52 
74 1018.52 
75 1018.52 
76 1018.52 
77 1019 
78 1019 
79 1019.26 
80 1078.3 
81 1078.3 
82 1078.3 
83 1078.3 
84 1078.3 


85 1078.3 
86 1078.3 
87 1078.55 
88 1078.55 
89 1078.55 
90 1078.55 
91 1078.55 
92 1078.69 
93 1078.69 
94 1078.69 
95 1078.69 
96 1078.69 
97 1078.69 
98 1078.73 
99 1078.73 
100 1078.73 
101 1078.73 
102 1078.73 
103 1078.73 
104 1144.2 
105 1144.21 

分成5組(每組之間雙空行)。

然後此:

plot for [IDX=0:4] 'prix.txt' index IDX u 1:2 with lp lt IDX+1 

產生這樣的: enter image description here

相關問題