0

I have a data in formatted in 10-columns as follow:

# col1 col2 col3 col4 col5 col6 col7 col8 col9 col10
    1    2   3     4    5    6    7    8    9    10
   11   12  13    14   15   16   17    18  19    20

I want to plot all the data individually as a single column,that is the 11th data will be 11 and so on. How can I do this in gnuplot directly?

example of the data can be obtained here: data

mas
  • 35
  • 5
  • What have you tried so far? What should be the x-values for plotting? – theozh Mar 10 '21 at 10:06
  • Hi @theozh..The x-values are the index values. So far I only use Excel to transpose the 10-column format into one-column and then simply plot that one-column data in Gnuplot. I am still trying to find how to do it in Gnuplot. – mas Mar 10 '21 at 10:39

1 Answers1

1

This is a bit a special data format. Well, you could rearrange it with whatever tools, but you can also rearrange with gnuplot only. For this, you need to have the data in a datablock. How to get it from a file into a datablock see the answer to this question: gnuplot: load datafile 1:1 into datablock

Code:

### plot special dataformat
reset session

$Data <<EOD
#SP# 12   10511.100
 265 7 2 5 2 10 6 10 4 4
 8 8 4 8 8 7 17 16 12 17
 9 23 18 16 18 26 18 31 31 38
 35 58 48 95 107 156 161 199 282 398
 448 704 851 1127 1399 1807 2272 2724 3376 4077
 4903 6458 7158 9045 9279 12018 13765 14212 17397 19166
 21159 23650 25537 28003 29645 35385 34328 36021 42720 39998
 45825 48111 49548 46591 53471 53888 56166 61747 57867 59226
 59888 65953 61544 68233 68770 69336 63925 69660 69781 70590
 76419 70791 70411 75909 70082 76136 69906 75069 75168 74690
 73897 73656 73134 77603 70795 77603 68092 74208 73385 66906
 71924 70866 74408 67869 67703 70924 65004 68566 62694 65917
 64636 62988 62372 64923 59231 58266 60636 59191 54090 56428
 55222 53519 52724 53973 49649 51418 46858 48289 46800 45395
 44235 43087 40999 42777 39129 40020 37985 37019 35739 34925
 33344 33968 30874 31292 30141 29528 27956 27001 25712 25842
 23857 23752 22900 21926 20853 19897 19063 18997 18345 16499
 16631 15810 15793 14158 13609 13429 13022 12276 11579 10810
 10930 9743 9601 8939 8762 8338 7723 7470 6815 6774
 6342 6056 5939 5386 5264 4889 4600 4380 4151 3982
 3579 3557 3335 3220 3030 2763 2769 2516 2409 2329
 2310 2153 2122 1948 1813 1879 1671 1666 1622 1531
 1584 1455 1430 1409 1345 1291 1300 1284 1373 1261
 1189 1373 1258 1220 1134 1261 1213 1116 1288 1087
 1113 1137 1182 1087 1213 1061 1132 1211 1004 1081
 1130 1144 1208 1089 1114 1088 1116 1188 1137 1150
 1216 1101 1092 1148 1115 1161 1262 1157 1206 1183
 1177 1274 1203 1150 1161 1206 1215 1166 1248 1217
 1212 1250 1239 1292 1226 1262 1209 1329 1178 1383
 1219 1175 1265 1264 1361 1206 1266 1285 1189 1284
 1330 1223 1325 1338 1250 1322 1256 1252 1353 1269
 1278 1281 1349 1256 1326 1309 1262 1374 1303 1293
 1350 1297 1262 1144 1305 1224 1259 1292 1447 1187
 1342 1267 1197 1327 1189 1248 1250 1198 1290 1299
 1233 1173 1327 1206 1231 1205 1182 1232 1233 1158
 1193 1137 1180 1211 1196 1176 1096 1131 1086 1134
 1125 1122 1090 1145 1053 1067 1097 1003 1044 993
 1056 1006 915 959 923 943 1026 930 927 929
 914 849 920 818 808 888 877 808 848 867
 735 785 769 738 744 716 708 677 660 657
 589 626 649 581 578 597 580 539 495 541
 528 402 457 435 425 417 415 408 366 375
 322 341 292 286 272 313 263 255 246 207
 213 176 195 180 181 168 153 140 114 130
 106 100 97 92 71 71 72 59 57 49
 43 42 35 38 36 26 33 29 29 14
 22 19 11 11 14 14 6 6 9 4
 7 5 2 5 1 3 0 0 0 2
 0 1 3 0 2 0 0 0 0 1
 1 0 3 1 0 1 2 1 2 0
 0 3 0 0 1 0 0 1 2 0
 1 0 0 0 0 0 0 1 2 0
 2 3 1 0 0 3 1 0 1 0
 0 1 0 1 1 0 0 1 0 0
 0 1 0 0 1 2 1 2 0 1
 1 1 0 0 0 0 0 0 0 2
 1 1 0 0 0 1 0 1 0 1
 1 1 1 1 1 0 0 3 0 2
 1 1 1 0 1 0 1 0 0 2
 1 1 0 1 0 0 0 1 0 1
 0 0 0 0 2 3 1 2 0 0
 1 2 0 1 2 1 1 1 1 1
 1 0 1 0 0 2 1 2 2 1
 0 0 1 1 1 0 1 1 1 0
 0 2 1 1 1 0 0 0 1 1
 0 2 1 1 2 0 2 1 1 1
 1 1 0 0 0 2 0 0 1 0
 1 0 1 1 2 2 0 0 0 3
 2 0 0 0 2 0 1 1 0 1
 0 0 0 2 1 4 0 1 0 1
 2 0 0 0 0 0 1 0 0 2
 0 0 0 0 1 0 0 0 0 0
 0 1 0 1 0 0 0 0 1 2
 0 0 1 0 1 0 0 1 0 1
 0 0 2 1 1 0 0 1 0 0
 0 0 0 1 0 0 0 0 0 1
 0 0 0 0 0 1 0 0 0 0
 0 0 0 0 0 0 0 1 0 0
 0 0 0 1 0 0 0 1 0 0
 1 0 0 0 0 0 0 0 0 0
 0 0 0 0 1 0 0 0 0 1
 0 0 1 2 0 0 0 0 0 0
 0 0 1 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 1 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 1 0 0 0 0 0 0 0
 0 0 0 0 0 0 1 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 1 0 0 0 0
 1 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0
EOD

set print $Data2
    HeaderLines = 1
    Line = ''
    do for [i=HeaderLines+1:|$Data|] {
        Line = Line.sprintf(' %s',$Data[i][1:strlen($Data[i])-1])
    }
    print Line
set print

WavStart = 450
WavStep  = 0.1
myWav(col) = WavStart + column(col)*WavStep
set grid x,y

plot $Data2 u (myWav(1)):0:3 matrix w l lc "red" notitle
### end of code

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72