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:

  1. save current terminal set terminal push
  2. set "fake" terminal set terminal unknown
  3. generate plot terminal (nothing plotted) in order force gnuplot initialize internal variables used in lines below
  4. check log scaling using gpval_x_log (equal 0 if logscale hasn't been set) , ranges gpval_x_min, gpval_x_max.
  5. revert terminal settings set terminal pop
  6. 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -