# Test of color modes for pm3d palettes.

#
# Multiplot with some of the recommended rgbformulae palettes
#
set view map
set style function pm3d
set multiplot layout 3,3 \
    title "Palettes according to 'help palette rgbformulae'"
g(x)=x
set xrange [0:1]; set xtics 0.2 scale 1.5 nomirror; set mxtics 2
# set palette maxcolors 128
unset colorbox; unset key; set tics out; unset ytics
set palette rgb 7,5,15; set title "traditional pm3d\n(black-blue-red-yellow)"; splot g(x)
set palette rgb 3,11,6; set title "green-red-violet"; splot g(x)
set palette rgb 23,28,3; set title "ocean (green-blue-white)\ntry also other permutations"; splot g(x)
set palette rgb 21,22,23; set title "hot (black-red-yellow-white)"; splot g(x)
set palette rgb 30,31,32; set title "color printable on gray\n(black-blue-violet-yellow-white)"; splot g(x)
set palette rgb 33,13,10; set title "rainbow (blue-green-yellow-red)"; splot g(x)
set palette rgb 34,35,36; set title "AFM hot (black-red-yellow-white)"; splot g(x)
set palette model HSV
set palette rgb 3,2,2; set title "HSV model\n(red-yellow-green-cyan-blue-magenta-red)"; splot g(x)
set pal gray; set title "gray palette"; splot g(x)
unset multiplot
reset
pause -1 "Hit return to continue"


#
#   Gradient Palettes
#
set view map
set style function pm3d
set palette color

f(x)=(x+10)/20
set cbrange [f(-10):f(10)] # [0:1]
set xrange [-10:10]
set yrange [*:*]
set xtics 2
set cbtics 0.1
set format cb "%3.1f"
unset ztics
unset ytics
set samples 101
set isosamples 2
unset key

set palette model RGB

set palette defined 
set title "set palette defined"
splot f(x)
pause -1 "Hit return to continue"

set palette defined (0 0 0 0, 1 0 0 1, 3 0 1 0, 4 1 0 0, 6 1 1 1)
set title 'set palette defined (0 0 0 0, 1 0 0 1, 3 0 1 0, 4 1 0 0, 6 1 1 1)'
splot f(x)
pause -1 "Hit return to continue"


set palette defined ( 0 "green", 1 "blue", 2 "red", 3 "orange" ) 
set title 'set palette defined ( 0 "green", 1 "blue", 2 "red", 3 "orange" )'
splot f(x)
pause -1 "Hit return to continue"


set palette defined ( 20 "#101010", 30 "#ff0000", 40 "#00ff00", 50 "#e0e0e0" ) 
set title 'set palette defined ( 20 "#101010", 30 "#ff0000", 40 "#00ff00", 50 "#e0e0e0" )'
splot f(x)
pause -1 "Hit return to continue"


set palette defined ( 0 0 0 0, 1 1 1 1 )
set title 'set palette defined ( 0 0 0 0, 1 1 1 1 )'
splot f(x)
pause -1 "Hit return to continue"


set palette model HSV defined ( 0 0 1 1, 1 1 1 1 )
set title 'set palette model HSV defined ( 0 0 1 1, 1 1 1 1 )'
splot f(x)
pause -1 "Hit return to continue"


set palette model RGB
set palette model RGB defined (0 "green", 1 "dark-green", 1 "yellow", 2 "dark-yellow", 2 "red", 3 "dark-red" )
set title "set palette model RGB defined\n(0 'green', 1 'dark-green', 1 'yellow', 2 'dark-yellow', 2 'red', 3 'dark-red' )"
splot f(x)
pause -1 "Hit return to continue"


set palette model RGB


set title 'set palette file "-" (file with 3 columns)'
set palette file "-"
0 0 0
0 0 1
0 1 0
1 0 0
1 1 1
e
splot f(x)
pause -1 "Hit return to continue"


set title 'set palette file (2 columns: gray + packed RGB)'
set datafile columnhead
$COLORS << EOD
gray colorname
10   black
20   blue
40   green
60   red
70   white
EOD
set palette file $COLORS using 1:(rgbcolor(strcol(2)))
test palette
pause -1 "Hit return to continue"


set title 'set palette file "-" using 1:2:($1+$2)/2'
set palette file "-" using ($0):1:2:(($1+$2)/2)
0 0
0 1
1 0
1 1
e
splot f(x)
pause -1 "Hit return to continue"



#
#    Color Models
#
set palette color
set view map
set xrange [-10:10]
unset ztics
unset ytics
set samples 101
set isosamples 2
set xtics 2

set palette rgbformulae 7,5,15

set palette model RGB rgbformulae 7,5,15
set title "set palette model RGB rgbformulae 7,5,15"
splot f(x)
pause -1 "Hit return to continue"


set palette model HSV rgbformulae 7,5,15
set title "set palette model HSV rgbformulae 7,5,15"
splot f(x)
pause -1 "Hit return to continue"


set palette model CMY rgbformulae 7,5,15
set title "set palette model CMY rgbformulae 7,5,15"
splot f(x)
pause -1 "Hit return to continue"


set palette model HSV rgbformulae 3,2,2
set title "set palette model HSV rrgbformulae 3,2,2"
splot f(x)
pause -1 "Hit return to continue"



#
#   User Defined Functions
#
set palette color
set view map
set cbrange [f(-10):f(10)]
set xrange [-10:10]
set yrange [0:1]
unset ztics
unset ytics
set samples 101
set isosamples 2
set xtics 2

set palette model RGB

set palette functions gray, gray, gray
set title "set palette functions gray, gray, gray"
splot f(x)
pause -1 "Hit return to continue"


set palette functions sqrt(gray), gray**3, sin(gray*2*pi) 
set title 'set palette functions sqrt(gray), gray**3, sin(gray*2*pi)  <--> 7,5,15'
splot f(x)
pause -1 "Hit return to continue"


set palette rgbformulae 7,5,15
set title 'set palette rgbformulae 7,5,15'
splot f(x)
pause -1 "Hit return to continue"


theta(x) = x<0 ? 0 : 1
r(x) = 4*x*(1-theta(x-0.25))
g(x) = 0.5*theta(x-0.25)*(1-theta(x-0.5))
b(x) = x
set palette model RGB functions r(gray),g(gray),b(gray)
set title "set palette model RGB functions\n4*x*(1-theta(x-0.25)), 0.5*theta(x-0.25)*(1-theta(x-0.5)), x"
splot f(x)
pause -1 "Hit return to continue"

unset datafile
reset

