NCL Home > Documentation > Graphics

Named colors

Named colors are colors with string names like "FireBrick" and "PapayaWhip" that have RGB triplets associated with them (see the file rgb.txt). They can be used to generate a color map (the background and foreground colors must be included), or to define a color or set of colors for a particular resource (like cnFillColors).

There are 650 named colors available in NCL. In order to use one of these named colors with a resource, it must be in your current color table. If it isn't, then a closest-match algorithm will be used to find the closest color, which may produce unexpected results.

You can see the color names and their associated colors by clicking on any one of the 15 tables below:

Note that some of the colors are duplicates, like "grey1" and "gray1".

Code snippets

The color names are case insensitive:

  colors = (/"white","black","White","RoyalBlue","LightSkyBlue",\
             "PowderBlue","lightseagreen","PaleGreen","Wheat","Brown",\
             "Pink"/)
  gsn_define_colormap(wks, colors)  

If you want to define a colormap using a combination of RGB triplets and named colors, you can do so by enclosing values in quotes:

  wks = gsn_open_wks("x11","example")

  cmap = (/"(/1.00, 1.00, 1.00/)", "(/0.00, 0.00, 0.00/)", \
           "(/.560, .500, .700/)", "(/.300, .300, .700/)", \
           "(/.100, .100, .700/)", "(/.000, .100, .700/)", \
           "(/.000, .300, .700/)", "(/.000, .500, .500/)", \
           "(/.000, .700, .100/)", "(/.060, .680, .000/)", \
           "(/.550, .550, .000/)", "(/.570, .420, .000/)", \
           "(/.700, .285, .000/)", "(/.700, .180, .000/)", \
           "(/.870, .050, .000/)", "(/1.00, .000, .000/)", \
           "CadetBlue", "Ivory", "LimeGreen", "DarkSalmon"/)

  gsn_define_colormap(wks,cmap)
To use a named color in a resource that expects a color index or an array of color indices, see the following code snippets. Remember that the color referenced must already be in your color table, otherwise you may get unexpected results.
  res@xyLineColor = "red"
  res@txFontColor = "Coral"
  res@cnFillColors = (/"LightSalmon","OliveDrab","AliceBlue","Purple"/)
  res@mpFillColors = (/"transparent","Gray1","gray25","gray5"/)