Gnuplot stats min does not detect negative numbers

Viewed 67

As you can see in this post gnuplot "stats" command unexpected min & "out of range" results, gnuplot stats take as the minimum value the minimum non-negative number avalaible in the column.

How can I include the negative numbers? My column has negative numbers and I want to have a negative number as a minimum for applying to the axis range.

Btw, I'm calling:

        stats mytextfile u 2:3 nooutput

But in fact later I have to call it again because I want to have the min and max values from 4 columns. Can I do it at once? Or do I have to do as I'm doing the following?:

    stats mytextfile u 2:3 nooutput
    do whatever
    stats mytextfile u 4:5 nooutput
    do whatever
2 Answers

As mentioned in the question and answer you linked to, stats will be done on the current x- and y-ranges. So, if you are in doubt just set the range [*:*], or [*:*][*:*] if you are using two columns. Depending on what exactly you want to do you could use this as a starting point.

Code:

### stats on several columns
reset session

$Data <<EOD
1  -0.1  -0.2  -0.3  -0.4
2   0.0   0.0   0.0   0.0
3   0.1   0.1   0.1   0.1
4   0.2   0.2   0.2   0.2
5   0.3   0.3   0.3   0.3
6   0.4   0.4   0.4   0.4
7   1.5   2.5   3.5   4.5
EOD

do for [i=2:5] {
    stats [*:*] $Data using i nooutput
    print sprintf("Column %d:  min: % 4g, max: % 4g",i, STATS_min, STATS_max)
}
### end of code

Result:

Column 2:  min: -0.1, max:  1.5
Column 3:  min: -0.2, max:  2.5
Column 4:  min: -0.3, max:  3.5
Column 5:  min: -0.4, max:  4.5

For the main question, put your range:

    stats [-9999:9999] mytextfile u 2:3 nooutput
Related