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
wksThe identifier returned from calling Ngl.open_wks.
colormap_nameThe 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.
optAn optional argument that allows you to customize the way the color map is drawn. See the description below.
Return value
NoneDescription
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():
- opt.Across (default: True)
If set to False, then the color boxes will be drawn top-to-bottom, left-to-right. - opt.LabelsOn (default: True)
If set to False, then the index numbers in each box will not be drawn. - opt.LabelStrings (default: None)
If set to to an array of strings, then these strings will be used in place of the color index numbers. - opt.LabelFontHeight (default: 0.015)
Allows you to change the size of the labels in the boxes.
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()