gnuplot - How to draw a number of plots for one function with multiple parameters? -


let's altitude-pressure function is:

 p(h) = p0 * exp(-h/scale) 

i'd want draw set of plots different planets; same graph (canvas) different p0 , scale parameters, pair (plus name of planet) per 1 planet.

do have enter "multiplot" , reassign scale = , p0 = before calling same plot p(h) every set of parameters or there neater way set of graphs this?

you can define 3 different space-separated string hold parameters , iterate on them:

p0 = "1 2 3 4" scale = "0.1 0.2 0.3 0.4" planets = "first second third fourth"  p(h, n) = (1.0*word(p0, n)) * exp(-h/(1.0*word(scale, n))) plot [i=1:words(planets)] p(x, i) title word(planets, i) 

the 1.0* used 'convert' respective string number. ugly, works. if want bit cleaner, define functions p0 , scale return number depending on iteration parameter

p0(n) = (n==1 ? 1 : n==2 ? 2 : n==3 ? 3 : 4) scale(n) = (n==1 ? 0.1 : n==2 ? 0.2 : n==3 ? 0.3 : 0.4) p(h, n) = p0(n)*exp(-h/scale(n)) plot [i=1:words(planets)] p(x, i) title word(planets, i) 

Comments