PyNGL Home > Functions > Color routines

Ngl.set_color

Sets a color in the color map of the given workstation.

Prototype

Ngl.set_color(wks, index, red, green, blue)

Arguments

wks

The identifier returned from calling Ngl.open_wks.

index

The index value in the color map of which to replace with the given color.

red, green, blue

Floating point values between 0.0 and 1.0 inclusive.

Description

For the given workstation, this procedure replaces the color in the color map of the given workstation, represented by index, with the given color (represented by an RGB triplet).

The index value must be between 0 and 255, and your current colormap must contain at least this many indices.

This procedure is different than the Ngl.new_color function in that you are required to give a color index value for where to put the new color.

See Also

Ngl.new_color, Ngl.draw_colormap, Ngl.get_named_color_index

Examples

For a simple example of using Ngl.set_color, run the following Python script:

import Ngl

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

#
# Draw the current color map.
#
Ngl.draw_colormap(wks)

#
# Add three shades of blue to the end of the colormap.
#
Ngl.set_color(wks,26,0.,0.,0.75)
Ngl.set_color(wks,27,0.,0.,0.50)
Ngl.set_color(wks,28,0.,0.,0.25)

#
# Draw the new current color map; it should have three shades
# of blue where there used to be shades of gray.
#
Ngl.draw_colormap(wks)

Ngl.end()