On his web page, Kenneth Moreland suggests a number of continuous and diverge color palettes to improve scientific visualization.[fn:1] Contrasting to other approaches, they aim for a smooth variation of the hue between the extremes of a scale displayed. While this reduces the brightness of the colors to choose from, their continuous transient hue offers a better visual inspection already when print in color. Contrasting to classical “jet” or “rainbow” palettes (vide infra), they retain their information if the output is constrained to gray scale (e.g., if xeroxed).
Where possible, this project renders Kenneth Moreland’s set of
.cvs
palette information accessible to gnuplot as .plt
files.
The color palettes are provided with a varying number of explicitly defined colors. This range spans from eight up to 1024. For smaller color palettes, a copy-paste of their content into an already existing gnuplot script file may be an option. More convenient however, especially while working with larger color palettes, is to access them from gnuplot by adding the command
load "example_palette.plt"
at any point prior to the [s]plot
instruction.
Each sub-folder contains the corresponding .plt
files. The number
in the file name indicates the number of explicitly defined colors
in the file.
For the display of continuous data, conversions of eight color
palettes are provided: black-body
, extended-black-body
,
inferno
, kindlmann
, extended-kindlmann
, magma
, plasma
, and
viridis
.
On the other hand, palette bent-cool-warm
is designed with diverge
data sets in mind where highlighting the transition across a
critical value is important. This may be useful to indicate
relative velocities, or pressures below / above a threshold, for
example. It is complemented by smooth-cool-warm
. While again
designed as diverging palette, the transition around the mid point
now is gradual. Thus, for data close at this transition, expect
less detail displayed there with with palette smooth-cool-warm
,
than with palette bent-cool-warm
.
The display of the palette’s action is based on synthetic data
computed for the Bessel function R
, G
, and B
channel sum
up to yield the RGB
color displayed. In addition, the NTSC
luminance value is traced. This is indicative about how the
calculated result would look like for an output constrained to
gray-scale. Thirdly you see the Bessel plot a twice, actually
simulating the gray-scale output.
A few palettes are compared to those provided by Moreland. They
again rely on the high level of isosamples (set iso 1024
) in z-,
and samples (set samples 500
) in x- and y-direction.
Repositories like gnuplot-colorbrewer,[fn:2] and gnuplot-palettes[fn:3] host alternative palettes, too.
- For the display of continuous data, either one of the following
instructions prior to the
[s]plot
instruction may initiate palettes already included in gnuplot:set palette gray # gnuplot's gray palette set pm3d map # access to gnuplot's default rainbow palette set palette cubehelix start 0 cycles -1. saturation 1
Note that palette
cubehelix
equally counters some cases of color blindness, too.As a contrasting example,
jet.pal
(provided by gnuplot-palettes) mimics an elder matlab default palette with the perceptual problems meanwhile addressed by palettes by Moreland and others. address. Its definitions relevant here are:set palette defined (0 0.0 0.0 0.5, \ 1 0.0 0.0 1.0, \ 2 0.0 0.5 1.0, \ 3 0.0 1.0 1.0, \ 4 0.5 1.0 0.5, \ 5 1.0 1.0 0.0, \ 6 1.0 0.5 0.0, \ 7 1.0 0.0 0.0, \ 8 0.5 0.0 0.0 )
- For diverge data, using a blue-white-red transient is a good
choice to begin with. For the RGB color space by the pngcairo
terminal, these palettes may be defined by ‘named colors’ as with
either of the example instructions below. Similar as seen with
Moreland’s palettes, it is helpful to decrease the maximal
luminosity, though (second example).
set palette defined (-1 "blue", 0 "white", 1 "red") set palette defined (-1 "blue", 0 "light-gray", 1 "red")
Departing from Moreland’s RGB palettes defined as floating
numbers, script csv2plt.py
(sub-folder tools
) reformatted the
entries to five decimals. Script RGB_check.py
provided a control
if the RGB tuples converted stay within the permitted interval of
Script palette_decomposition.py
provided a quick channel-wise
decomposition of the RGB color space, complemented by the NTSC
luminosity. Each synopsis per .plt
file displays this result in
between the test plots in color and gray-scale.
Script bessel_test_center.py
computed the synthetic data of the
Bessel function palette_decomposition.py
.
Gnuplot’s rapid scrutiny about the contribution of R
, G
, and B
channel of a palette, reported as .png
, allows a programmatic
visual comparison of palettes with each other. This task addressed
by script vignette_comparison.py
, to be run right after
palette_decomposition.py
, without provision of parameters from the
CLI by
python3 vignette_comparison.py
Each pairwise comparison yields a new file named in the pattern of
diff_fileA_fileB.png
. Differences identified by ImageMagick will
be indicated with bright red pixels. This reveals, for example,
palette magma.pal
provided by gnuplotting.org[fn:4] /
gnuplot-palettes differs from all magma.plt
definitions derived
from Kenneth Moreland’s palettes based on floating numbers in this
repository as illustrated below, or with animation magma_diff.gif
(in sub-folder extra_palette_tests
).
Sub-folder extra_palette_tests/magma_testing/
includes further
details about this analysis and an animated .gif
about all tests
performed relevant here. This and all other data processing was
run under Linux (Xubuntu 18.04.3 LTS) with CPython (3.6.8,
October 7, 2019), gnuplot (5.2.7beta, last modified 2019-05-14), and
ImageMagick (6.9.7-4 Q16).
It is possible to engage gnuplot’s set terminal pdfcairo
instruction to provide a native export of the results as the
resolution independent .pdf
format. This was tested for the
palette maps of 512 explicitly defined colors with now 256 iso
samples computed by gnuplot for the same Bessel function. While
this document contains only the example for the continuously smooth
viridis palette, tests with this and the other palettes are stored
in sub-folder pdf-tests
.
./pdf_tests/viridis-table-float-0512_test.pdf
[fn:1] http://www.kennethmoreland.com/color-advice/ [fn:2] https://github.com/aschn/gnuplot-colorbrewer [fn:3] https://github.com/Gnuplotting/gnuplot-palettes [fn:4] http://www.gnuplotting.org/