Base Options

Control Options

Color Settings

** - Setting region to load 'set lon -20 40' 'set lat 30 85' ** - Map projection 'set mpdset hires' 'set mproj nps' 'set mpvals -10 30 34 52' ** - Plotting relative humidity on 850 hPa 'set gxout shaded' 'set lev 850' 'd rhprs' 'set gxout contour' 'd rhprs' ** Labeling 'set string 3 l' 'draw string 1 1 NCEP GFS 1 deg analysis: relative humidity 850hPa'
## Note: example as seen on matplotlib webpage (2013-08-26): ## - ## Only adapted color handling ## Loading necessary python modules for this example from numpy.random import uniform, seed from matplotlib.mlab import griddata import matplotlib.pyplot as plt import numpy as np ## make up data. seed(0) npts = 200 x = uniform(-2,2,npts) y = uniform(-2,2,npts) z = x*np.exp(-x**2-y**2) ## define grid. xi = np.linspace(-2.1,2.1,100) yi = np.linspace(-2.1,2.1,200) ## grid the data. zi = griddata(x,y,z,xi,yi,interp='linear') ## contour the gridded data, plotting dots at the nonuniform data points. CS = plt.contour(xi,yi,zi,len(colors)-1,linewidths=0.5,colors='k') CS = plt.contourf(xi,yi,zi,len(colors)-1,colors=colors, vmax=abs(zi).max(), vmin=-abs(zi).max()) plt.colorbar() # draw colorbar ## plot data points. plt.scatter(x,y,marker='o',c='b',s=5,zorder=10) plt.xlim(-2,2) plt.ylim(-2,2) plt.title('griddata test (%d points)' % npts)
%% Create surface data [X,Y] = meshgrid(-8:.5:8); R = sqrt(X.^2 + Y.^2) + eps; Z = sin(R)./R; %% Plotting surface surf(X,Y,Z,'EdgeColor','black') %% Adding your color palette and colorbar colormap(colors) colorbar()


Jason C. Fisher, Reto Stauffer, Achim Zeileis

Graphical User Interface for Choosing HCL Color Palettes


A graphical user interface (GUI) for viewing, manipulating, and choosing HCL color palettes.


Computes palettes based on the HCL (hue-chroma-luminance) color model (as implemented by polarLUV). The GUIs interface the palette functions rainbow_hcl for qualitative palettes, sequential_hcl for sequential palettes with a single hue, heat_hcl for sequential palettes with multiple hues, and diverge_hcl for diverging palettes (composed from two single-hue sequential palettes).

Two different GUIs are implemented and can be selected using the function input argument gui ("tcltk" or "shiny"). Both GUIs allows for interactive modification of the arguments of the respective palette-generating functions, i.e., starting/ending hue (wavelength, type of color), minimal/maximal chroma (colorfulness), minimal maximal luminance (brightness, amount of gray), and a power transformations that control how quickly/slowly chroma and/or luminance are changed through the palette. Subsets of the parameters may not be applicable depending on the type of palette chosen. See rainbow_hcl and Zeileis et al. (2009) for a more detailed explanation of the different arguments. Stauffer et al. (2015) provide more examples and guidance.

Optionally, active palette can be illustrated by using a range of examples such as a map, heatmap, scatter plot, perspective 3D surface etc.

To demonstrate different types of deficiencies, the active palette may be desaturated (emulating printing on a grayscale printer) and, if the dichromat package is available, collapsed to emulate different types of color-blindness (without red-green or green-blue contrasts).


Returns a palette-generating function with the selected arguments. Thus, the returned function takes an integer argument and returns the corresponding number of HCL colors by traversing HCL space through interpolation of the specified hue/chroma/luminance/power values.

HCL and HSV Color Palettes


Color palettes based on the HCL and HSV color spaces.


All functions compute palettes based on either the HCL (polarLUV) or the HSV (HSV) color space.

rainbow_hcl computes a rainbow of colors (qualitative palette) defined by different hues given a single value of each chroma and luminance. It corresponds to rainbow which computes a rainbow in HSV space.

sequential_hcl gives a sequential palette starting at the full color HCL(h, c[1], l[1]) through to a light color HCL(h, c[2], l[2]) by interpolation.

diverge_hcl and diverge_hsv, compute a set of colors diverging from a neutral center (gray or white, without color) to two different extreme colors (blue and red by default). This is similar to cm.colors. For the diverging HSV colors, two hues h are needed, a maximal saturation s and a fixed value v. The saturation is then varied to obtain the diverging colors. For the diverging HCL colors, again two hues h are needed, a maximal chroma c and two luminances l. The colors are then created by an interpolation between the full color HCL(h[1], c, l[1]), a neutral color HCL(h, 0, l[2]) and the other full color HCL(h[2], c, l[1]).

The palette heat_hcl gives an implementation of heat.colors in HCL space. By default, it goes from a red to a yellow hue, while simultaneously going to lighter colors (i.e., increasing luminance) and reducing the amount of color (i.e., decreasing chroma). The terrain_hcl palette simply calls heat_hcl with different parameters, providing colors similar in spirit to terrain.colors. The lighter colors are not strictly HCL colors, though.


A character vector with (s)RGB codings of the colors in the palette.

Color Spectrum Plot


Visualization of color palettes (given as hex codes) in RGB and/or HCL coordinates.


The function specplot transforms a given color palette in hex codes into their RGB (sRGB) or HCL (polarLUV) coordinates. As the hues for low-chroma colors are not (or poorly) identified, by default a smoothing is applied to the hues (fix = TRUE). Also, to avoid jumps from 0 to 360 or vice versa, the hue coordinates are shifted suitably.

By default (plot = TRUE) the resulting RGB and HCL coordinates are visualized by simple line plots along with the color palette x itself.


specplot invisibly returns a list with components


a matrix of sRGB coordinates,


a matrix of HCL coordinates,


original color palette x.


Zeileis A, Hornik K, Murrell P (2009). Escaping RGBland: Selecting Colors for Statistical Graphics. Computational Statistics & Data Analysis, 53, 3259–3270. doi: 10.1016/j.csda.2008.11.033 Preprint available from

Stauffer R, Mayr GJ, Dabernig M, Zeileis A (2015). Somewhere over the Rainbow: How to Make Effective Use of Colors in Meteorological Visualizations. Bulletin of the American Meteorological Society, 96(2), 203–216. doi: 10.1175/BAMS-D-13-00155.1