Colormaps

Colormaps

This package provides some pre-defined colormaps (described below). There are also several other packages which provide colormaps:

Predefined sequential and diverging colormaps

The colormap() function returns a predefined sequential or diverging colormap computed using the algorithm by Wijffelaars, M., et al. (2008).

colormap(cname::String [, N::Int=100; mid=0.5, logscale=false, kvs...])

The optional arguments are:

Colormaps computed by this algorithm are guaranteed to have an increasing perceived depth or saturation making them ideal for data visualization. This also means that they are (in most cases) color-blind friendly and suitable for black-and-white printing.

The currently supported colormap names are:

Sequential

NameExample
BluesBlues
GreensGreens
Grays
OrangesOranges
PurplesPurples
RedsReds

Diverging

NameExample
RdBu (from red to blue)RdBu
Colors.colormapFunction.
colormap(cname, [N; mid, logscale, kvs...])

Returns a predefined sequential or diverging colormap computed using the algorithm by Wijffelaars, M., et al. (2008).

Sequential colormaps cname choices are:

  • Blues
  • Greens
  • Grays
  • Oranges
  • Purples,
  • Reds

Diverging colormap choices are RdBu.

Optionally, you can specify the number of colors N (default 100). Keyword arguments include the position of the middle point mid (default 0.5) and the possibility to switch to log scaling with logscale (default false).

Sequential and diverging color palettes

You can create your own color palettes by using sequential_palette():

sequential_palette(h, [N::Int=100; c=0.88, s=0.6, b=0.75, w=0.15, d=0.0, wcolor=RGB(1,1,0), dcolor=RGB(0,0,1), logscale=false])

which creates a sequential map for a hue h (defined in LCHuv space).

Other possible parameters that you can fine tune are:

Two sequential maps can also be combined into a diverging colormap by using:

diverging_palette(h1, h2 [, N::Int=100; mid=0.5,c=0.88, s=0.6, b=0.75, w=0.15, d1=0.0, d2=0.0, wcolor=RGB(1,1,0), dcolor1=RGB(1,0,0), dcolor2=RGB(0,0,1), logscale=false])

where the arguments are:

and the optional arguments are:

sequential_palette(h, N::Int=100; <keyword arguments>)

Implements the color palette creation technique by Wijffelaars, M., et al. (2008).

Colormaps are formed using Bézier curves in LCHuv colorspace with some constant hue. In addition, start and end points can be given that are then blended to the original hue smoothly.

Arguments

  • N - number of colors
  • h - the main hue [0,360]
  • c - the overall lightness contrast [0,1]
  • s - saturation [0,1]
  • b - brightness [0,1]
  • w - cold/warm parameter, i.e. the strength of the starting color [0,1]
  • d - depth of the ending color [0,1]
  • wcolor - starting color (warmness)
  • dcolor - ending color (depth)
  • logscale - true/false for toggling logspacing
diverging_palette(h1, h2, N::Int=100; <keyword arguments>)

Create diverging palettes by combining 2 sequential palettes

Arguments

  • N - number of colors
  • h1 - the main hue of the left side [0,360]
  • h2 - the main hue of the right side [0,360]
  • c - the overall lightness contrast [0,1]
  • s - saturation [0,1]
  • b - brightness [0,1]
  • w - cold/warm parameter, i.e. the strength of the starting color [0,1]
  • d1 - depth of the ending color in the left side [0,1]
  • d2 - depth of the ending color in the right side [0,1]
  • wcolor - starting color (warmness)
  • dcolor1 - ending color of the left side (depth)
  • dcolor2 - ending color of the right side (depth)
  • logscale - true/false for toggling logspacing