/Graphics-Gnuplot-Palettes

A collection of high-quality palettes for surface plots made using Gnuplot

Primary LanguagePerlArtistic License 2.0Artistic-2.0

Graphics-Gnuplot-Palettes

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.

Installation

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.

Overview

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");

Palette groups

Gnuplot suggestions

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 moduleRGB valuesexplanation
Pm3d7,5,15traditional pm3d (black-blue-red-yellow)
GRV3,11,6green-red-violet
Ocean23,28,3ocean (green-blue-white); try also all other permutations
Hot21,22,23hot (black-red-yellow-white)
Grey30,31,32color printable on gray (black-blue-violet-yellow-white)
Rainbow33,13,10rainbow (blue-green-yellow-red)
AFMHot34,35,36AFM hot (black-red-yellow-white)

Color Brewer

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 moduleexplanation
Diverging_BrBG.pmBrown to green, centered about white
Diverging_PRGn.pmPurple to green, centered about white
Diverging_PiYG.pmPink to green, centered about yellow
Diverging_PuOr.pmPurple to orange, centered about white
Diverging_RdBu.pmRed to blue, centered about white
Diverging_RdGy.pmRed to gray, centered about white
Diverging_RdYlBu.pmRed to blue, centered about yellow
Diverging_RdYlGn.pmRed to green, centered about yellow
Diverging_Spectral.pmRainbow, centered about yellow
Qualitative_Accent.pmPastels and saturated colors
Qualitative_Dark2.pmSaturated colors
Qualitative_Paired.pmPaired pastel and saturated
Qualitative_Pastel1.pmAll pastels
Qualitative_Pastel2.pmAll pastels
Qualitative_Set1.pmSaturated colors
Qualitative_Set2.pmDesaturated but not pastel
Qualitative_Set3.pmLess saturated, still not pastel
Sequential_Blues.pmWhite to blue
Sequential_BuGn.pmWhite to blue to green
Sequential_BuPu.pmWhite to blue to purple
Sequential_GnBu.pmWhite to green to blue
Sequential_Greens.pmWhite to green
Sequential_Greys.pmWhite to gray
Sequential_OrRd.pmWhite to orange to red
Sequential_Oranges.pmWhite to orange
Sequential_PuBu.pmWhite to purple to blue
Sequential_PuBuGn.pmWhite to purple to blue to green
Sequential_PuRd.pmWhite to purple to red
Sequential_Purples.pmWhite to purple
Sequential_RdPu.pmWhite to red to purple
Sequential_Reds.pmWhite to red
Sequential_YlGn.pmWhite to yellow to green
Sequential_YlGnBu.pmWhite to yellow to green to blue
Sequential_YlOrBr.pmWhite to yellow to orange to brown
Sequential_YlOrRd.pmWhite to yellow to orange to red

Matlab-like palettes

This set implements common Matlab color palettes in Gnuplot form.

perl moduleexplanation
ParulaSimilar to Matlab’s current default
JetThe standard matlab rainbow

Color Map Advice for Scientific Visualization

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 moduleexplanation
SmoothCoolWarmDiverging (double-ended) blue-white-red color map with a smooth transition in the middle to prevent artifacts at the midpoint
BentCoolWarmLike above but interpolated linearly with a sharp bend in the middle
BlackBodyBased on colors from black-body radiation
ExtendedBlackBodyLike above but with blue and purple hues
KindlmannRainbow color map with the luminance adjusted such that it monotonically changes
ExtendedKindlmannLike above but adds more hues by doing a more than 360 degree loop around the hues

CET Perceptually Uniform Colour Maps

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:

symbolwordexplanation
Ccycliccolors that are matched at each end with first order continuity
Iisoluminantconstructed from colours of equal perceptual lightness
Llinearcolor lightness values that increase or decrease linearly over the colour map’s range
Ddivergentfollow some pattern of symmetry about their center
RBrainbownominally 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 moduleoriginal name
L_greylinear_grey_0-100_c0
L_krywlinear_kryw_5-100_c67
L_krylinear_kry_5-98_c75
L_greenlinear_green_5-95_c69
L_bluelinear_blue_5-95_c73
L_bmwlinear_bmw_5-95_c89
L_bmylinear_bmy_10-95_c78
L_bgywlinear_bgyw_15-100_c68
L_gowlinear_gow_60-85_c27
L_bluelinear_blue_95-50_c20
L_ternary-redlinear_ternary-red_0-50_c52
L_ternary-greenlinear_ternary-green_0-46_c42
L_ternary-bluelinear_ternary-blue_0-44_c57
D_bwrdiverging_bwr_40-95_c42
D_gwvdiverging_gwv_55-95_c39
D_gwrdiverging_gwr_55-95_c38
D_bkrdiverging_bkr_55-10_c35
D_bkydiverging_bky_60-10_c30
D_L_bjydiverging-linear_bjy_30-90_c45
D_L_bjrdiverging-linear_bjr_30-55_c53
D_bwrdiverging_bwr_55-98_c37
D_cwmdiverging_cwm_80-100_c22
D_RB_bgymrdiverging-rainbow_bgymr_45-85_c67
RB_bgyrmrainbow_bgyrm_35-85_c71
RB_bgyrrainbow_bgyr_35-85_c73
C_mrybmcyclic_mrybm_35-75_c68
C_mygbmcyclic_mygbm_30-95_c78
C_wrwbwcyclic_wrwbw_40-90_c42
C_greycyclic_grey_15-85_c0
I_cgoisoluminant_cgo_70_c39
I_cmisoluminant_cm_70_c39
D_I_cjodiverging-isoluminant_cjo_70_c25
D_I_cjmdiverging-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.

http://peterkovesi.com/projects/colourmaps/NamingConvention.png

  • 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 - redg - greenb - blue
    c - cyanm - magentay - yellow
    o - orangev - violet
    k - blackw - whitej - 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.

Others