If control sequence under Gnuplot

Courier picture Courier · Dec 3, 2013 · Viewed 35.9k times · Source

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.

Answer

Christoph picture Christoph · Dec 3, 2013

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]
}