Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If control sequence under Gnuplot

How to perform control sequences under Gnuplot please? I need to make something like

if (x == nan)
  set xrange[]

else
  set xrange[10:30]

I tried something like

( x > 100000 ) ?  (set xrange[]) : (set xrange[10:30])

... buth without success! I spent hours trying to solve this!! Any help please? At worst I can create a shell script an manage this, but I think there should be some control sequences to fix this.

like image 240
Courier Avatar asked Dec 03 '13 19:12

Courier


1 Answers

For gnuplot 4.4.4 the if statement must be on a single line:

if (x > 10000) set autoscale x; else set xrange [10:30]

or use \ to continue on the next line.

if (x > 10000) \
    set autoscale x; \
else \
    set xrange [10:30]

Since 4.6.0 gnuplot can use brackets to delimit the branches:

if (x > 10000) {
    set autoscale x
} else {
    set xrange [10:30]
}
like image 152
Christoph Avatar answered Oct 22 '22 06:10

Christoph