1#
2# Set up a color mapping for vectors in the complex plane similar to the one
3# used on Wikipedia for plotting complex trigonometric functions.
4# HSV colors
5#	Hue is the vector angle atan( Real(f) / Imaginary(f) )
6#	Saturation is the vector magnitude (length)
7#	V = 1
8#
9save_encoding = GPVAL_ENCODING
10set encoding utf8
11
12# We don't use the palette for plotting, but defining it allows us to
13# draw a colorbar showing the phase angle color scheme
14set palette model HSV defined ( 0 0 1 1, 1 1 1 1 )
15set cbrange [-pi : pi]
16set cbtics ("0" -pi, "2π" pi)
17set cblabel "Phase Angle" rotate offset -2,0
18
19Hue(x,y) = (pi + atan2(-y,-x)) / (2*pi)
20phase(x,y) = hsv2rgb( Hue(x,y), sqrt(x**2+y**2), 1. )
21
22set xrange [-pi/2. : pi/2.]
23set yrange [-pi/2. : pi/2.]
24set urange [-pi/2. : pi/2.]
25set vrange [-pi/2. : pi/2.]
26set xtics ("-π/2" -pi/2., "-π/4" -pi/4., "0" 0, "π/4" pi/4., "π/2" pi/2.)
27set ytics ("-π/2" -pi/2., "-π/4" -pi/4., "0" 0, "π/4" pi/4., "π/2" pi/2.)
28
29set view map; set size square; unset key
30set isosamples 100,100
31
32set title "Color (Hue) indicates angle\nSaturation indicates amplitude"
33splot '++' using 1:2:(phase($1,$2)) with pm3d lc rgb variable
34
35pause -1
36
37rp(x,y) = real(f(x,y))
38ip(x,y) = imag(f(x,y))
39color(x,y) = hsv2rgb( Hue( rp(x,y), ip(x,y) ), abs(f(x,y)), 1. )
40
41set title "asin( x + iy )"
42f(x,y) = asin(x + y*{0,1})
43splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
44pause -1
45
46set title "acos( x + iy )"
47f(x,y) = acos(x + y*{0,1})
48splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
49pause -1
50
51set title "atan( x + iy )"
52f(x,y) = atan(x + y*{0,1})
53splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
54pause -1
55
56set title "sinh( x + iy )"
57f(x,y) = sinh(x + y*{0,1})
58splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
59pause -1
60
61set title "cosh( x + iy )"
62f(x,y) = cosh(x + y*{0,1})
63splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
64pause -1
65
66set title "tanh( x + iy )"
67f(x,y) = tanh(x + y*{0,1})
68splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
69pause -1
70
71set title "asinh( x + iy )"
72f(x,y) = asinh(x + y*{0,1})
73splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
74pause -1
75
76set title "acosh( x + iy )"
77f(x,y) = acosh(x + y*{0,1})
78splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
79pause -1
80
81set title "atanh( x + iy )"
82f(x,y) = atanh(x + y*{0,1})
83splot '++' using 1:2:(color($1,$2)) with pm3d lc rgb variable
84pause -1
85
86#
87# The final plot is atanh() again, but this time we represent
88# the magnitude as a z-coordinate.  The angle in the complex
89# plane is colored as before.
90#
91
92set view 66, 336, 1.2, 1.2
93set view equal xyz
94set colorbox user origin 0.85, 0.2
95unset ztics
96set zlabel "magnitude" rotate offset 3
97set xlabel "Real" rotate parallel offset 0,-2
98set ylabel "Imaginary" rotate parallel offset 0,-2
99set grid x y
100set xyplane at 0.0
101set border -1
102
103splot '++' using 1:2:(abs(f($1,$2))):(color($1,$2)) with pm3d lc rgb variable
104
105pause -1
106
107#
108set encoding save_encoding
109reset
110