Credits | Overview | Plotting Styles | Commands | Terminals |
---|
Arithmetic operations and most built-in functions support the use of complex arguments. Complex constants are expressed as {<real>,<imag>}, where <real> and <imag> must be numerical constants. Thus {0,1} represents 'i'. The program predefines a variable I = {0,1} on entry that can be used to generate complex values in terms of other variables. Thus x + y*I is a valid expression but {x,y} is not. The real and imaginary components of complex value z can be extracted as real(z) and imag(z). The modulus is given by abs(z). The phase angle is given by arg(z).
Gnuplot's 2D and 3D plot styles expect real values; to plot a complex-valued function f(z) with non-zero imaginary components you must plot the real or imaginary component, or the modulus or phase. For example to represent the modulus and phase of a function f(z) with complex argument and complex result it is possible to use the height of the surface to represent modulus and use the color to represent the phase. It is convenient to use a color palette in HSV space with component H (hue), running from 0 to 1, mapped to the range of the phase returned by arg(z), [-π:π], so that the color wraps when the phase angle does. By default this would be at H = 0 (red). You can change this with the start keyword in set palette so that some other value of H is mapped to 0. The example shown starts and wraps at H = 0.3 (green). See set palette defined, arg, set angles.
set palette model HSV start 0.3 defined (0 0 1 1, 1 1 1 1) set cbrange [-pi:pi] set cbtics ("-π" -pi, "π" pi) set pm3d corners2color c1 E0(z) = exp(-z)/z I = {0,1} splot '++' using 1:2:(abs(E0(x+I*y))):(arg(E0(x+I*y))) with pm3d