Reversing IDL's Color Tables

QUESTION: I like the color tables that come with IDL, but I want the colors reversed. How can I do that?

ANSWER: There are several ways to reverse the color tables in IDL. One way is to just move the Stretch Top and Stretch Bottom sliders on the XLOADCT program to their opposite ends. But here is a short program that can do it too.

   PRO Reverse_CT
   TVLCT, r, g, b, /Get
   TVLCT, Reverse(r), Reverse(g), Reverse(b)

Save the program as "", compile it, and type "reverse_ct" whenever you want to use it.

   IDL> .Compile reverse_ct
   IDL> Reverse_CT

If you use cgLoadCT to load your color tables, you can simply set the Reverse keyword to reverse the color table you are loading:

   IDL> cgLoadCT, 5, /REVERSE

[Return to IDL Programming Tips]