Actually, this feature request originates from here: https://sourceforge.net/p/gnuplot/bugs/2539/
In a matrix you have row- and column-indices.
I expected to be able to use these indices like in normal tabular data via the pseudocolumns.
column(-1) seems to be the row index
column(1) seems to be the nonuniform x-values
column(2) seems to be the nonuniform y-values
column(3) seems to be the z-values
Consequently, I hoped that column(0) is the column index,
but apparently it seems to be int(column(3)).
Am I getting something wrong here?
Tested with gnuplot 5.0.0 and 5.4.1
Script:
### column indices in matrix
$Data <<EOD
X 1 3 7
0 11.1 21.2 31.3
2 12.1 22.2 32.3
5 13.1 23.2 33.3
9 14.1 24.2 34.3
EOD
set table $Test
plot $Data nonuniform matrix u -2:-1:0:1:2:3 w table
unset table
print $Test
### end of script
Result:
0 0 11 1 0 11.1
0 0 21 3 0 21.2
0 0 31 7 0 31.3
0 1 12 1 2 12.1
0 1 22 3 2 22.2
0 1 32 7 2 32.3
0 2 13 1 5 13.1
0 2 23 3 5 23.2
0 2 33 7 5 33.3
0 3 14 1 9 14.1
0 3 24 3 9 24.2
0 3 34 7 9 34.3
Why would anyone need the integer values of the matrix values in column(0)?
The wish would be to assign the column index of a nonuniform to column(0), unless it might interfere with or mess up some current or legacy binary matrix functions.
Maybe a change might as well affect the use of every ::startLine:startBlock:endLine:endBlock together with a uniform (or nonuniform) matrix?
Here you go:
Last edit: Ethan Merritt 2022-08-18
Thank you very much!
Actually, I hoped to directly have the column index in
column(0). As you write, now I have to always determineMfirst, which is (to my opinion) an avoidable extra step (for the user in the script). Why should I be interested in linear order numbers of values in a matrix (unlike in tabular data)? I would say only row and column index are of importance and you can calculate the linear order if (at all) needed.column(0)/Mwould be redundant, because I have the row-index already incolumn(-1).Although, I have to admit I don't know what is going on "behind the scenes" in the source code, maybe the linear values are easier for programming? I assume gnuplot is reading data line by line and hence doesn't know
Mat that time. gnuplot would have to determineMfirst (in an extra step, which I don't have to care as user). Well, now it is analog to tabular data wherecolumn(0)is the linear ordered row-index. Anyway, for sure it is an improvement. Thank you again!Sorry, again... for curiosity:
Currently, in both matrices (uniform and nonuniform),
column(0)is the "useless" integer ofcolumn(3).So, instead (to my opinion) the column index could/should be put there.
Then for a uniform matrix
column(2) == column(-1)andcolumn(1) == column(0). This would be redundant but doesn't hurt.For a uniform matrix the following script
returns:
So, "technically" it seems to be possible to put the column index into
column(1), so why not intocolumn(0)for both matrix types?For a nonuniform matrix_,
column(1)andcolumn(2)already contain the nonuniform x- and y-values, respectively.If
column(0)is the column index, you could easily (without extra steps) plot a (nonuniform) matrix as uniform matrix by ignoring the nonuniform x,y values just via adding the keywordnonuniform.Otherwise it would be:
which I wouldn't call very user-friendly.
Is there any practical example where you would need the linear index of a matrix?