Search code examples
gnuplotsuppress-warnings

Gnuplot: How to disable "WARNING: Plotting with an 'unknown' terminal."?


In a Gnuplot file, I am using the following "subroutine" file to compute dimensions of some table:

# Sets:
# size_x ,min_x, max_x,
# size_y, min_y, max_y.

# Dummy plot to get statistical properties without
# having "stats" command like with v4.4.4.

set terminal unknown
# Works with v4.4
# if ($# == 1) plot $0 using 1:2; else plot $0 using $1

# Works with v5.5
if (ARGC == 1) plot ARG1 using 1:2; else plot ARG1 using @ARG2

min_x = GPVAL_DATA_X_MIN
max_x = GPVAL_DATA_X_MAX
min_y = GPVAL_DATA_Y_MIN
max_y = GPVAL_DATA_Y_MAX

size_x = max_x - min_x
size_y = max_y - min_y

so there is a deliberate set terminal unknown because the script is not suposed to display anything, but only to compute some values.

I tried set terminal in a Gnuplot prompt, but it seems there is no dummy or null terminal...

Is there a way to get rid of that message?

I am currently using Gnuplot v5.4.2.


Solution

  • If you use gnuplot 5.4.2 (actually gnuplot>=4.6.0, March 2012) then simply do it with stats (which was not available in v4.4.). Check help stats and type show var STATS in the gnuplot console to see the parameters which are calculated.

    stats "myFile.dat" u 1:2 nooutput
    
    size_x = STATS_max_x - STATS_min_x
    size_y = STATS_max_y - STATS_min_y
    
    print size_x, size_y