Functions

Arguments to math functions in gnuplot can be integer, real, or complex unless otherwise noted. Functions that accept or return angles (e.g. sin(x)) treat angle values as radians, but this may be changed to degrees using the command set angles.

Math library functions
Function Arguments Returns
     
abs(x) any absolute value of 11#11, 12#12; same type
abs(x) complex length of 11#11, 13#13
acos(x) any 14#14 (inverse cosine)
acosh(x) any 15#15 (inverse hyperbolic cosine) in radians
airy(x) any Airy function Ai(x)
arg(x) complex the phase of 11#11
asin(x) any 16#16 (inverse sin)
asinh(x) any 17#17 (inverse hyperbolic sin) in radians
atan(x) any 18#18 (inverse tangent)
atan2(y,x) int or real 19#19 (inverse tangent)
atanh(x) any 20#20 (inverse hyperbolic tangent) in radians
EllipticK(k) real k 21#21 (-1:1) 22#22 complete elliptic integral of the first kind
EllipticE(k) real k 21#21 [-1:1] 23#23 complete elliptic integral of the second kind
EllipticPi(n,k) real n4#41, real k 21#21 (-1:1) 24#24 complete elliptic integral of the third kind
besj0(x) int or real 25#25 Bessel function of 11#11 in radians
besj1(x) int or real 26#26 Bessel function of 11#11 in radians
besjn(n,x) int, real 27#27 Bessel function of 11#11 in radians
besy0(x) int or real 28#28 Bessel function of 11#11 in radians
besy1(x) int or real 29#29 Bessel function of 11#11 in radians
besyn(n,x) int, real 30#30 Bessel function of 11#11 in radians
besi0(x) real Modified Bessel function of order 0, 11#11 in radians
besi1(x) real Modified Bessel function of order 1, 11#11 in radians
besin(n,x) int, real Modified Bessel function of order n, 11#11 in radians
ceil(x) any 31#31, smallest integer not less than 11#11 (real part)
cos(x) any 32#32, cosine of 11#11
cosh(x) any 33#33, hyperbolic cosine of 11#11 in radians
erf(x) any 34#34, error function of real(11#11)
erfc(x) any 35#35, 1.0 - error function of real(11#11)
exp(x) any 36#36, exponential function of 11#11
expint(n,x) int 37#37, real 38#38 39#39, exponential integral of 11#11
floor(x) any 40#40, largest integer not greater than 11#11 (real part)
gamma(x) any 41#41, gamma function of real(11#11)
ibeta(p,q,x) any 42#42, ibeta function of real(43#43,44#44,11#11)
inverf(x) any inverse error function of real(11#11)
igamma(a,x) any 45#45, igamma function of real(46#46,11#11)
imag(x) complex imaginary part of 11#11 as a real number
invnorm(x) any inverse normal distribution function of real(11#11)
int(x) real integer part of 11#11, truncated toward zero
lambertw(x) real Lambert W function
lgamma(x) any 47#47, lgamma function of real(11#11)
log(x) any 48#48, natural logarithm (base 49#49) of 11#11
log10(x) any 50#50, logarithm (base 51#51) of 11#11
norm(x) any normal distribution (Gaussian) function of real(11#11)
rand(x) int pseudo random number in the open interval (0:1)
real(x) any real part of 11#11
sgn(x) any 1 if 52#52, -1 if 53#53, 0 if 54#54. imag(11#11) ignored
sin(x) any 55#55, sine of 11#11
sinh(x) any 56#56, hyperbolic sine of 11#11 in radians
sqrt(x) any 57#57, square root of 11#11
tan(x) any 58#58, tangent of 11#11
tanh(x) any 59#59, hyperbolic tangent of 11#11 in radians
voigt(x,y) real Voigt/Faddeeva function 60#60
    Note: voigt61#61 = 62#62faddeeva63#63
     

Special functions from libcerf (only if available)
Function Arguments Returns
     
cerf(z) complex complex error function
cdawson(z) complex complex extension of Dawson's integral 64#64
faddeeva(z) complex rescaled complex error function 65#65
erfi(x) real imaginary error function 66#66
VP(x,67#67,68#68) real Voigt profile 69#69
     

String functions
Function Arguments Returns
gprintf("format",x,...) any string result from applying gnuplot's format parser
sprintf("format",x,...) multiple string result from C-language sprintf
strlen("string") string number of characters in string
strstrt("string","key") strings int index of first character of substring "key"
substr("string",beg,end) multiple string "string"[beg:end]
strftime("timeformat",t) any string result from applying gnuplot's time parser
strptime("timeformat",s) string seconds since year 1970 as given in string s
system("command") string string containing output stream of shell command
trim(" string ") string string without leading or trailing whitespace
word("string",n) string, int returns the nth word in "string"
words("string") string returns the number of words in "string"

other gnuplot functions
Function Arguments Returns
column(x) int or string column 11#11 during datafile manipulation.
columnhead(x) int string containing first entry of column 11#11 in datafile.
exists("X") string returns 1 if a variable named X is defined, 0 otherwise.
hsv2rgb(h,s,v) h,s,v 21#21 [0:1] 24bit RGB color value.
palette(z) double RGB palette color mapped to z.
stringcolumn(x) int or string content of column 11#11 as a string.
timecolumn(N,"timeformat") int, string time data from column 70#70 during data input.
tm_hour(t) time in sec the hour (0..23)
tm_mday(t) time in sec the day of the month (1..31)
tm_min(t) time in sec the minute (0..59)
tm_mon(t) time in sec the month (0..11)
tm_sec(t) time in sec the second (0..59)
tm_wday(t) time in sec the day of the week (Sun..Sat) as (0..6)
tm_week(t) time in sec week of year in ISO8601 "week date" system (1..53)
tm_yday(t) time in sec the day of the year (0..365)
tm_year(t) time in sec the year
time(x) any the current system time in seconds
valid(x) int test validity of 71#71 during datafile manip.
value("name") string returns the value of the named variable.
voxel(x,y,z) real value of the active grid voxel containing point (x,y,z)


Subsections