NCL Home > Documentation > Graphics > Graphical Interfaces


Merges two color maps and sets this as the color map for the given workstation.


load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  ; This library is automatically loaded
                                                          ; from NCL V6.2.0 onward.
                                                          ; No need for user to explicitly load.

	procedure gsn_merge_colormaps (
		wks     [1] : graphic,  
		color_map1  ,           



A Workstation identifier. The identifier is one returned either from calling gsn_open_wks or calling create to create a Workstation object.


The two color maps to merge. They can be string arrays of named colors, arrays of red/blue/green (RGB) triplets, and/or predefined color maps.


This procedure merges two color maps and sets this as the new color map for the given workstation.

Note: this procedure must be used if you have NCL V6.0.0 or earlier, and want to use more than one color map per page of graphics. If you have V6.1.0 or later and are drawing color contours, vectors, or streamlines, then you can associate a color map directly with a contour, vector, or streamline plot using these special resources: cnFillPalette, vcLevelPalette, and stLevelPalette.

If the second color map is a list of RGB values or a predefined color map, then the foreground and background colors will be dropped from this color map before it is appended to the first color map. If the second color map is a list of named colors, then all of the named colors will be appended.

Since there's a limit of 256 colors in a color map associated with a workstation, the sum total of colors in the two color maps must be less than or equal to 256.

You can use the gsn_draw_colormap procedure to draw the color map (mostly for debugging purposes).

See Also

draw_color_palette, gsn_define_colormap, gsn_retrieve_colormap, gsn_reverse_colormap, gsn_draw_colormap, gsn_draw_named_colors, read_colormap_file


load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"

  wks = gsn_open_wks("ncgm","gsn_merge_colormaps")

;---Merge two pre-defined colormaps;

;---Generate grayscale color map.
  gcmap = new((/11,3/),float)
  gcmap(:,0) = ispan(0,10,1)/10.
  gcmap(:,1) = gcmap(:,0)
  gcmap(:,2) = gcmap(:,0)

;---Append grayscale map to the end of a Blue-White-Red color map.

See also the suite of color and color map examples.