Menu

#1739 "stats .. matrix" range settings

None
closed-fixed
nobody
stats (6)
2016-02-12
2016-02-09
No

(from a discussion on the c.g.a.gnuplot newsgroup)

"stats .. matrix" does not accept a range specifier on the second axis (neither inline nor with "set yr"), a second inline range spec limits the zrange instead.

Further, some plot commands interfere with "stats .. matrix", so that while the records are read in correctly (9 total, 0 out of range), the displayed statistics are nonsense.

  $dat << EOD
  1 2 3
  2 3 4
  3 4 5
  EOD

  stats $dat matrix  # works OK
  splot $dat
  stats $dat matrix # nonsense output
  plot $dat
  stats $dat matrix  # works OK again

I guess it might be that the y/z ranges in the current plot mix up the ranges for stats?
(I'm on v. 5.0.pl1)

Discussion

  • Ethan Merritt

    Ethan Merritt - 2016-02-09
    • status: open --> open-not-a-bug
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2016-02-09

    plot/splot/stats/fit on matrix data returns x coord in col 1, y coord in col 2, and matrix value in col 3
    So you want

    stats $dat matrix using 3
    splot $dat
    stats $dat matrix using 3
    plot $dat
    stats $dat matrix using 3

    The "nonsense output" you saw without "using 3" is the min/mean/max of column 1 (matrix indices 0/1/2).

    Arguably stats should default to "using 3" if it recognizes that the input is matrix data. I'm not sure if that'a a trivial fix or whether the data has already been read in before it realizes that this was a matrix, which would be too late.

     
  • Karl Ratzsch

    Karl Ratzsch - 2016-02-09

    OK, "stats $dat matrix using 3" always gives the correct statistics (against the docs, which says that with "matrix", a "using" statement is ignored, which makes sense of course), but with my example, the first "stats $dat matrix" command also gives the correct results.

    Only the "splot" command makes it switch to in fact doing "stats $dat matrix us 1". And "plot" rectifies it again.

     
  • Ethan Merritt

    Ethan Merritt - 2016-02-09

    That would be an error in the documentation. Where did you find that exactly?
    Ignoring the using spec could never be correct. What if you want to use the matrix value in a function, as in:
    plot FOO matrix using (f($3))

    I had a quick look at the source, but I could not see where it sets any default column for the 'using' spec in a stats command. Your test case seems to end up with the correct default (3) for 'plot' and something else for 'splot', but so far I can't find where in the code would change that.

     
  • Karl Ratzsch

    Karl Ratzsch - 2016-02-09

    "help stats", halfway down the page: "When matrix is specified, the using option is ignored ..."

     
  • Ethan Merritt

    Ethan Merritt - 2016-02-09

    Now I see it. I'll fix the documentation and keep looking for a fix to incorrect outcome from matrix with no using spec.

     
  • Ethan Merritt

    Ethan Merritt - 2016-02-11
    • status: open-not-a-bug --> pending-fixed
     
  • Ethan Merritt

    Ethan Merritt - 2016-02-12
    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.