That is possible, if you have a palette defined in terms of three functions, or if you have a data file which holds the palette values.
Consider, you have a mapping function map(x)
(i.e. your self-defined function) which maps from [0:1] -> [0:1]
and stretches/shrinks the gray range. Then you could use:
red(x) = ...
green(x) = ...
blue(x) = ...
map(x) = ...
set palette functions red(map(gray)), green(map(gray)), blue(map(gray))
And accordingly for a file:
map(x) = ...
set palette file 'palette.dat' using (map($1)):2:3:4
In your case you can:
- Define the palette like you want (e.g. with
set palette defined ...
) - Write the palette to an external data file. This writes one data set for 'red', one for 'green', one for 'blue' and one for the NTSC gray value.
Rearrange the data file to be useful for
set palette file
. Here I use the following python scriptpalette.py
:import numpy as np import sys A = np.loadtxt(sys.stdin, usecols=(0,1)) np.savetxt(sys.stdout, A.reshape(256,8, order='F')[:,(0,4,5,6,7)], fmt='%.3f')
Define an appropriate
map(x)
function.
Here is the script:
# 1.
set palette defined (1 "#B0E2FF", 2 "#87CEFA", 3 "#7EC0EE", 4 "#4F94CD", 5 "#4E78A0", 6 "#104E8B", 7 "#1B3F8B", 8 "#162252")
# 2.
set terminal push
set terminal unknown
set table 'palette.tmp'
test palette
unset table
set terminal pop
# 3.
system('python palette.py < palette.tmp > palette.dat')
# 4.
map(x) = (-0.5+(2*(x-0.5))**3 + x)/3 + 0.5
set palette file 'palette.dat' using (map($1)):2:3:4
test palette