Blame demo/complex_trig.dem

Packit 0986c0
#
Packit 0986c0
# Set up a color mapping for vectors in the complex plane similar to the one
Packit 0986c0
# used on Wikipedia for plotting complex trigonometric functions.
Packit 0986c0
# HSV colors
Packit 0986c0
#	Hue is the vector angle atan( Real(f) / Imaginary(f) )
Packit 0986c0
#	Saturation is the vector magnitude (length)
Packit 0986c0
#	V = 1
Packit 0986c0
#
Packit 0986c0
save_encoding = GPVAL_ENCODING
Packit 0986c0
set encoding utf8
Packit 0986c0
Packit 0986c0
# We don't use the palette for plotting, but defining it allows us to
Packit 0986c0
# draw a colorbar showing the phase angle color scheme
Packit 0986c0
set palette model HSV defined ( 0 0 1 1, 1 1 1 1 )
Packit 0986c0
set cbrange [-pi : pi]
Packit 0986c0
set cbtics ("0" -pi, "2π" pi)
Packit 0986c0
set cblabel "Phase Angle" rotate offset -2,0
Packit 0986c0
Packit 0986c0
Hue(x,y) = (pi + atan2(-y,-x)) / (2*pi)
Packit 0986c0
phase(x,y) = hsv2rgb( Hue(x,y), sqrt(x**2+y**2), 1. )
Packit 0986c0
Packit 0986c0
set xrange [-pi/2. : pi/2.]
Packit 0986c0
set yrange [-pi/2. : pi/2.]
Packit 0986c0
set urange [-pi/2. : pi/2.]
Packit 0986c0
set vrange [-pi/2. : pi/2.]
Packit 0986c0
set xtics ("-π/2" -pi/2., "-π/4" -pi/4., "0" 0, "π/4" pi/4., "π/2" pi/2.)
Packit 0986c0
set ytics ("-π/2" -pi/2., "-π/4" -pi/4., "0" 0, "π/4" pi/4., "π/2" pi/2.)
Packit 0986c0
Packit 0986c0
set view map; set size square; unset key
Packit 0986c0
set isosamples 100,100
Packit 0986c0
Packit 0986c0
set title "Color (Hue) indicates angle\nSaturation indicates amplitude"
Packit 0986c0
splot '++' using 1:2:(phase($1,$2)) with pm3d lc rgb variable
Packit 0986c0
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
rp(x,y) = real(f(x,y))
Packit 0986c0
ip(x,y) = imag(f(x,y))
Packit 0986c0
color(x,y) = hsv2rgb( Hue( rp(x,y), ip(x,y) ), abs(f(x,y)), 1. )
Packit 0986c0
Packit 0986c0
set title "asin( x + iy )"
Packit 0986c0
f(x,y) = asin(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "acos( x + iy )"
Packit 0986c0
f(x,y) = acos(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "atan( x + iy )"
Packit 0986c0
f(x,y) = atan(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "sinh( x + iy )"
Packit 0986c0
f(x,y) = sinh(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "cosh( x + iy )"
Packit 0986c0
f(x,y) = cosh(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "tanh( x + iy )"
Packit 0986c0
f(x,y) = tanh(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "asinh( x + iy )"
Packit 0986c0
f(x,y) = asinh(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "acosh( x + iy )"
Packit 0986c0
f(x,y) = acosh(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
set title "atanh( x + iy )"
Packit 0986c0
f(x,y) = atanh(x + y*{0,1})
Packit 0986c0
splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
#
Packit 0986c0
# The final plot is atanh() again, but this time we represent
Packit 0986c0
# the magnitude as a z-coordinate.  The angle in the complex
Packit 0986c0
# plane is colored as before.
Packit 0986c0
#
Packit 0986c0
Packit 0986c0
set view 66, 336, 1.2, 1.2
Packit 0986c0
set view equal xyz
Packit 0986c0
set colorbox user origin 0.85, 0.2
Packit 0986c0
unset ztics
Packit 0986c0
set zlabel "magnitude" rotate offset 3
Packit 0986c0
set xlabel "Real" rotate parallel offset 0,-2
Packit 0986c0
set ylabel "Imaginary" rotate parallel offset 0,-2
Packit 0986c0
set grid x y
Packit 0986c0
set xyplane at 0.0
Packit 0986c0
set border -1
Packit 0986c0
Packit 0986c0
splot '++' using 1:2:(abs(f($1,$2))):(color($1,$2)) with pm3d lc rgb variable
Packit 0986c0
Packit 0986c0
pause -1
Packit 0986c0
Packit 0986c0
#
Packit 0986c0
set encoding save_encoding
Packit 0986c0
reset