in a gnuplot script how to go access the range -
i call function in gnuplot session, , know ranges , if logscale used inside function. how ? thank you
gnuplot> load 'myfunction.gnu'   the file myfunction.gnu:
if "logscale" {do this};else {do that}      
partial solution follows. let's main script looks like:
set logscale x set xr [10:100]  load 'my_function.gpl'   then in my_function.gpl, do:
set terminal push set terminal unknown plot 1 islogscale = (gpval_x_log > 0)?1:0 xmin = gpval_x_min xmax = gpval_x_max set terminal pop  if(islogscale){     print "logscale" }else{     print "..." }   the idea to:
- save current terminal 
set terminal push - set "fake" terminal 
set terminal unknown - generate plot terminal (nothing plotted) in order force gnuplot initialize internal variables used in lines below
 - check log scaling using 
gpval_x_log(equal 0 iflogscalehasn't been set) , rangesgpval_x_min,gpval_x_max. - revert terminal settings 
set terminal pop - perform action using information
 
however, catch although set logscale x sets gpval_x_log default 10, unset logscale not revert zero, if 1 used set logscale x;unset logscale, code snippet above not handle correctly...
in opinion, better solution introduce custom variable in main script as:
uselogscale = 1  if(uselogscale){     set logscale x }  set xr [10:100]  load 'my_function.gpl'   then variable uselogscale directly available in my_function.gpl.
Comments
Post a Comment