I print force fields for various functions and x and y ranges like for f in the following almost minimal example:
f(x,y) = -x*y
unset key
set xrange [-2:2]
set yrange [-1:1]
set samples 40
set isosamples 20
delta = 2.0 / 41
ds(x,y) = sqrt(1.0+f(x,y)**2)
plot "++" using ($1):($2):(delta/ds($1,$2)):(delta*f($1,$2)/ds($1,$2)) with vectors
How can I use in the calculation of delta the current values of internal settings such as samples and isosamples and x and y ranges in order to adapt the lengths of the little arrows to their mutual distances so that arrows are well visible but do not overlap?
Background is that I want to split the above code into two files, the first to define f and the range and sample settings and then load the rest. The rest than can be re-used to plot force fields for many functions.
It would be possible to circumvent the read-access to gnuplot settings by defining variables and then set xrange and yrange etc. according to these. I would, however, prefer to use the gnuplot built-in set command if this is possible.
I know that there are variables GPVAL_X_MIN, GPVAL_X_MAX, GPVAL_Y_MIN and GPVAL_Y_MAX after the first time, plot is invoked. It would be preferable not to require a plot and only read the setting from the preceding set xrange and set yrange.
And is there any gnuplot-defined variable for samples and isosamples? Is there anything like GPVAL_SAMPLES and GPVAL_ISOSAMPLES?
SAMPLES=20; set samples SAMPLES... BTW, withshow variables GPVALyou can see all variables starting with "GPVAL" - Christoph