|
From: theozh <th...@gm...> - 2017-12-15 21:17:46
|
Hi Iva,
thanks for your reply. I tried again, and voilà... there is a way, although again not very elegant.
Maybe, somebody else might find it useful...
It's really a pitty that gnuplot is not supporting at least very simple table manipulations,
e.g. reversing data, transposing data arrays, copying columns or rows and/or putting columns side by side to arrange new arrays...
Sure, you can use other scripting languages to manipulate data and generate gnuplot scripts.
Well, it would be nice if you can do it "monolithically" without any wrappers...
The intended result of the script below is:
1 10 111 211
1 20 121 221
1 30 131 231
1 40 141 241
2 10 112 212
2 20 122 222
2 30 132 232
2 40 142 242
3 10 113 213
3 20 123 223
3 30 133 233
3 40 142 242
### Merge and rearrange two datablocks or files
reset
$Data1 <<EOD
0 1 2 3
10 111 112 113
20 121 122 123
30 131 132 133
40 141 142 142
EOD
$Data2 <<EOD
0 1 2 3
10 211 212 213
20 221 222 223
30 231 232 233
40 241 242 242
EOD
stats $Data1 nooutput
print "Rows: ".STATS_records."\n"."Columns: ".STATS_columns
set print $Data3
set table $Nowhere # plot data to "nowhere" to avoid unnecessary plot windows
do for [i=2:STATS_columns] {
do for [j=1:STATS_records-1] {
plot $Data1 u (a=column(i),1/0) every ::0::0 with table
plot $Data1 u (b=column(1),1/0):(c=column(i),1/0) every ::j::j with table
plot $Data2 u (d=column(i),1/0) every ::j::j with table
print sprintf("%g\t%g\t%g\t%g",a,b,c,d)
}
print "" # separat blocks by empty line
}
set print
print $Data3
### end gnuplot code
|