Why is terminal size undefined after gnuplot startup?

Viewed 64

After startup of gnuplot (console) even without specifying a terminal and a canvas size there are default values defined, in my case wxt and 640,384.

Without having plotted anything, if I type in console or use in a script:

print GPVAL_TERM_XSIZE, GPVAL_TERM_YSIZE

I will get an error:

undefined variable: GPVAL_TERM_XSIZE

I know that many other GVPAL_... variables depend on the plot and the data itself. So, it's clear that they are only defined if you have plotted something.

But why are GPVAL_TERM_XSIZE and GPVAL_TERM_YSIZE undefined after startup if there are default values? Even if I specify a size, the following will still give the same error:

set term wxt size 500,400
print GPVAL_TERM_XSIZE, GPVAL_TERM_YSIZE

I know that I can (or I have to) do some dummy plot to initialize the GPVAL_TERM_XSIZE and GPVAL_TERM_YSIZE values. But why is this necessary? Thank you for explanations.

1 Answers

On program entry the name of the current terminal (usually the default one but you might have changed it in ./gnuplot) is printed to the console. But the terminal is not actually opened until the first plot command. This allows time for you to change the terminal or set different terminal properties before plotting. When the terminal is first opened, it fills in various GPVAL_TERM values including its current size.

The GPVAL_* program variables are updated after every plot command. Those that are dependent on the most recent plot, including all the GPVAL_TERM_* variables, don't exist until after the first plot.

Related