PyNGL Home > Functions > Color routines

Ngl.draw_color_palette

Draws the given color map and advances the frame.

Available in version 1.5.0 or later.

Prototype

Ngl.draw_color_palette(wks,colormap_name,opt)

Arguments

wks

The identifier returned from calling Ngl.open_wks.

colormap_name

The name of the color map to draw, like "rainbow". If this is not set, then the color map currently associated with the workstation will be drawn.

opt

An optional argument that allows you to customize the way the color map is drawn. See the description below.

Return value

   None

Description

This procedure draws the given color map and advances the frame. If no color map is given, then the current colormap associated with the given workstation is drawn.

By default, the colors are drawn as filled boxes going from left-to-right, top-to-bottom, with the color index numbers (starting at 0) included in the lower left corner of each box.

Here's a list of options you can include with opt, set it is set to Ngl.Resources():

This procedure is different from Ngl.draw_colormap, which draws the color map associated with the given workstation.

For a list of the available color maps, see the predefined color maps, or you can create your own.

See Also

Ngl.read_colormap_file, Ngl.draw_colormap, Ngl.retrieve_colormap, Ngl.open_wks, Ngl.draw

Examples

Example 1

A simple example of using Ngl.draw_color_palette to draw the "amwg256" color map:

import Ngl

wks = Ngl.open_wks("x11","amwg256")

Ngl.draw_color_palette(wks,"amwg256")

Ngl.end()
Example 2

To draw two color maps without any labels:

import Ngl

wks = Ngl.open_wks("x11","example")

opt = Ngl.Resources()
opt.LabelsOn = False
for cmap in ["cb_rainbow","StepSeq25"]:
  print("Drawing color map '%s'..." % cmap)
  Ngl.draw_color_palette(wks,cmap,opt)

Ngl.end()