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:

  • the number of colors N
  • position of the middle point mid
  • the use of logarithmic scaling with the logscale keyword

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

  • "Blues"
  • "Greens"
  • "Grays"
  • "Oranges"
  • "Purples"
  • "Reds"

Diverging

  • "RdBu" (from red to blue)
Colors.colormapFunction
colormap(cname, N=100; mid=0.5, logscale=false, 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).

Extra control is provided by keyword arguments.

  • mid sets the position of the midpoint for diverging colormaps.
  • logscale=true uses logarithmically-spaced steps in the colormap.

You can also use keyword argument names that match the argument names in sequential_palette or diverging_palette.

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:

  • N - number of colors
  • 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 (usually defined to be yellow)
  • dcolor - ending color (depth)
  • logscale - true/false for toggling logspacing

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:

  • h1 - the main hue of the left side [0,360]
  • h2 - the main hue of the right side [0,360]

and the optional arguments are:

  • N - number of colors
  • 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 middle color [0,1]
  • d1 - depth of the end color in the left side [0,1]
  • d2 - depth of the end color in the right side [0,1]
  • wcolor - starting color i.e. the middle color (warmness, usually defined to be yellow)
  • dcolor1 - end color of the left side (depth)
  • dcolor2 - end color of the right side (depth)
  • logscale - true/false for toggling logspacing
Colors.sequential_paletteFunction
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
Colors.diverging_paletteFunction
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