A collection of high-quality palettes for surface plots made using Gnuplot.
This is useful for any Perl-to-Gnuplot interface, including PDL::Graphics::Gnuplot, Graphics::GnuplotIF, and probably others.
This installs like any perl package:
perl Makefile.PL make make test sudo make install
The make test
test step is fairly trivial. When run in that way,
the test only checks to see that the module loads and that the
introspection functions work. Proper testing that all the palettes
are defined correctly requires human interaction to see that each
palette in the collection works. This is done by visual comparison
with the default palette. To run the tests interactively do, for
instance, perl -Iblib/lib test.t
in the main directory.
To use this in a perl program:
use Graphics::Gnuplot::Palette;
my $colors = palette("BlackBody");
send_to_gnuplot_process("set palette $colors");
To invert the color palette, do
send_to_gnuplot_process("set palette negative $colors");
A specific example for PDL::Graphics::Gnuplot:
use Graphics::Gnuplot::Palette;
my $w = PDL::Graphics::Gnuplot -> new();
$w->image({palette=>palette("Kindlmann")}, $image_pdl);
To invert the color palette, do
$w->image({palette=>"negative ".palette("Kindlmann")}, $image_pdl);
The palette
method is exported by default and takes as its argument
one of the perl module names listed in the tables below. In the case
of a name collision, you can specify the palette group also, like so:
my $colors = palette("Moreland", "BlackBody");
In the two-argument form, the named palette will be searched for only among that palette group. In the one-argument form, the first one found by that name is returned.
If the requested palette name cannot be found, the function returns the string defining Gnuplot’s traditional pm3d palette. In that way, something sensible will always be plotted.
There are also introspection functions which return lists of groups and palette names:
my @groups = palette_groups();
my @all_names = palette_names();
my @CET_names = palette_names("CET");
This set of color maps implements the suggested RGB values from the
set palette
section of the Gnuplot manual.
The traditional pm3d palette is the return value for the palette method when it cannot figure out which palette you are asking for. The other are quite similar to offerings in the CET group.
perl module | RGB values | explanation |
---|---|---|
Pm3d | 7,5,15 | traditional pm3d (black-blue-red-yellow) |
GRV | 3,11,6 | green-red-violet |
Ocean | 23,28,3 | ocean (green-blue-white); try also all other permutations |
Hot | 21,22,23 | hot (black-red-yellow-white) |
Grey | 30,31,32 | color printable on gray (black-blue-violet-yellow-white) |
Rainbow | 33,13,10 | rainbow (blue-green-yellow-red) |
AFMHot | 34,35,36 | AFM hot (black-red-yellow-white) |
This set implements the Gnuplot translations of Color Brewer 2.0.
Diverging color schemes are good for emphasizing both extremes of ordered data. Sequential color schemes are good for emphasizing one extreme of ordered data. Qualitative color schemes are good for comparing data sets without emphasizing any inherent ordering.
perl module | explanation |
---|---|
Diverging_BrBG.pm | Brown to green, centered about white |
Diverging_PRGn.pm | Purple to green, centered about white |
Diverging_PiYG.pm | Pink to green, centered about yellow |
Diverging_PuOr.pm | Purple to orange, centered about white |
Diverging_RdBu.pm | Red to blue, centered about white |
Diverging_RdGy.pm | Red to gray, centered about white |
Diverging_RdYlBu.pm | Red to blue, centered about yellow |
Diverging_RdYlGn.pm | Red to green, centered about yellow |
Diverging_Spectral.pm | Rainbow, centered about yellow |
Qualitative_Accent.pm | Pastels and saturated colors |
Qualitative_Dark2.pm | Saturated colors |
Qualitative_Paired.pm | Paired pastel and saturated |
Qualitative_Pastel1.pm | All pastels |
Qualitative_Pastel2.pm | All pastels |
Qualitative_Set1.pm | Saturated colors |
Qualitative_Set2.pm | Desaturated but not pastel |
Qualitative_Set3.pm | Less saturated, still not pastel |
Sequential_Blues.pm | White to blue |
Sequential_BuGn.pm | White to blue to green |
Sequential_BuPu.pm | White to blue to purple |
Sequential_GnBu.pm | White to green to blue |
Sequential_Greens.pm | White to green |
Sequential_Greys.pm | White to gray |
Sequential_OrRd.pm | White to orange to red |
Sequential_Oranges.pm | White to orange |
Sequential_PuBu.pm | White to purple to blue |
Sequential_PuBuGn.pm | White to purple to blue to green |
Sequential_PuRd.pm | White to purple to red |
Sequential_Purples.pm | White to purple |
Sequential_RdPu.pm | White to red to purple |
Sequential_Reds.pm | White to red |
Sequential_YlGn.pm | White to yellow to green |
Sequential_YlGnBu.pm | White to yellow to green to blue |
Sequential_YlOrBr.pm | White to yellow to orange to brown |
Sequential_YlOrRd.pm | White to yellow to orange to red |
This set implements common Matlab color palettes in Gnuplot form.
perl module | explanation |
---|---|
Parula | Similar to Matlab’s current default |
Jet | The standard matlab rainbow |
This set of color maps is from Kenneth Moreland following the principles in his paper, “Why We Use Bad Color Maps and What You Can Do About It.” Kenneth Moreland. In Proceedings of Human Vision and Electronic Imaging (HVEI), 2016. (To appear.) See also his web site http://www.kennethmoreland.com/color-advice
perl module | explanation |
---|---|
SmoothCoolWarm | Diverging (double-ended) blue-white-red color map with a smooth transition in the middle to prevent artifacts at the midpoint |
BentCoolWarm | Like above but interpolated linearly with a sharp bend in the middle |
BlackBody | Based on colors from black-body radiation |
ExtendedBlackBody | Like above but with blue and purple hues |
Kindlmann | Rainbow color map with the luminance adjusted such that it monotonically changes |
ExtendedKindlmann | Like above but adds more hues by doing a more than 360 degree loop around the hues |
This set of color maps is designed to have uniform perceptual contrast over their whole range. See http://peterkovesi.com/projects/colourmaps/
All palettes in this group are the work of Peter Kovesi of The University of Western Australia. They are used under the terms of the Creative Commons BY License. For more information, see the website or Kovesi’s paper Good Colour Maps: How to Design Them, (arXiv:1509.03700 [cs.GR] 2015)
The palettes in this group were generated from this XML file using a script in this repository.
The language used in Kovesi’s palettes was a little unwieldy for this purpose, so I adopted a file name shortening scheme as follows:
symbol | word | explanation |
---|---|---|
C | cyclic | colors that are matched at each end with first order continuity |
I | isoluminant | constructed from colours of equal perceptual lightness |
L | linear | color lightness values that increase or decrease linearly over the colour map’s range |
D | divergent | follow some pattern of symmetry about their center |
RB | rainbow | nominally follow some representation of the color spectrum |
And here are is the connection between perl module names and original color map names. The astute will note that a couple of the originals are lost due to the file name shortening scheme.
perl module | original name |
---|---|
L_grey | linear_grey_0-100_c0 |
L_kryw | linear_kryw_5-100_c67 |
L_kry | linear_kry_5-98_c75 |
L_green | linear_green_5-95_c69 |
L_blue | linear_blue_5-95_c73 |
L_bmw | linear_bmw_5-95_c89 |
L_bmy | linear_bmy_10-95_c78 |
L_bgyw | linear_bgyw_15-100_c68 |
L_gow | linear_gow_60-85_c27 |
L_blue | linear_blue_95-50_c20 |
L_ternary-red | linear_ternary-red_0-50_c52 |
L_ternary-green | linear_ternary-green_0-46_c42 |
L_ternary-blue | linear_ternary-blue_0-44_c57 |
D_bwr | diverging_bwr_40-95_c42 |
D_gwv | diverging_gwv_55-95_c39 |
D_gwr | diverging_gwr_55-95_c38 |
D_bkr | diverging_bkr_55-10_c35 |
D_bky | diverging_bky_60-10_c30 |
D_L_bjy | diverging-linear_bjy_30-90_c45 |
D_L_bjr | diverging-linear_bjr_30-55_c53 |
D_bwr | diverging_bwr_55-98_c37 |
D_cwm | diverging_cwm_80-100_c22 |
D_RB_bgymr | diverging-rainbow_bgymr_45-85_c67 |
RB_bgyrm | rainbow_bgyrm_35-85_c71 |
RB_bgyr | rainbow_bgyr_35-85_c73 |
C_mrybm | cyclic_mrybm_35-75_c68 |
C_mygbm | cyclic_mygbm_30-95_c78 |
C_wrwbw | cyclic_wrwbw_40-90_c42 |
C_grey | cyclic_grey_15-85_c0 |
I_cgo | isoluminant_cgo_70_c39 |
I_cm | isoluminant_cm_70_c39 |
D_I_cjo | diverging-isoluminant_cjo_70_c25 |
D_I_cjm | diverging-isoluminant_cjm_75_c24 |
The original file names are explained in an image from Kovesi’s web site. The following text is copied from there. Examples are given for each color map at the web site.
- A colour map may have more than one attribute. For example, diverging-isoluminant (D_I).
- Lightness values can range from 0 to 100. For linear colour maps the two lightness values indicate the first and last lightness values in the map. For diverging colour maps the second value indicates the lightness value of the centre point of the colour map (unless it is a diverging-linear colour map). For cyclic and rainbow colour maps the two values indicate the minimum and maximum lightness values. Isoluminant colour maps have only one lightness value.
- The string of characters indicating the nominal hue sequence uses
the following code
r - red g - green b - blue c - cyan m - magenta y - yellow o - orange v - violet k - black w - white j - grey (‘j’ rhymes with grey). Thus a ‘heat’ style colour map would be indicated by the string ‘kryw’. If the colour map is predominantly one colour then the full name of that colour may be used. Note these codes are mainly used to indicate the hues of the colour map independent of the lightness/darkness and saturation of the colors.
- Mean chroma/saturation is an indication of vividness of the color map. A value of 0 corresponds to a grey scale. A value of 50 or more will indicate a vivid colour map.
- Depending on whether a cyclic colour map is being used to render data that is cyclic over 360 or 180 degrees a cyclic shift of 25% may be applied.