Color in postscript using IDL

Some notes by Eric Weeks, August 18, 2016

Lab Home -- People -- Experimental facilities -- Publications -- Experimental pictures -- Links

I figured out how to use nicer colors for making plots. In fact, we'll start with nice colors and then move on to arbitrary colors.

I tend to make IDL scripts to produce plots. At the top of the script I put this:


The key line is the "loadct" command which loads this file: ericcol.tbl. I made a custom color palette based on the "cubehelix less-angry rainbow". It is saved as palette #76 in the color table file. This then lets you use colors 0-255 in plotting to refer to the colors in the color table. For example:


The 'plot' command will make a black graph. I used /nodata so that no data would be plotted in black; I want to plot the data in other colors. The two oplot commands plot the cosine and sine in red and dark blue, respectively. Here are some useful colors in this color table:

21reddish purple
187light blue-green
216dark blue
255dark purple

At the end of the IDL script making the figure, put:


Note that you can use the built-in IDL command XLOADCT to examine all the default color tables. #3 "red temperature" is the one that's often used for AFM plots, for example (that goes from black --> dark red --> red --> orange --> white). To use that color table, you could do:


where now you don't have to specify a file, you're just loading in one of the default color tables that IDL has built-in.

How to make your own color table

Use the MODIFYCT command. For example:

modifyct,77,'darker rainbow w/ black',col(0,*),col(1,*),col(2,*),$

using which transforms black & white values into the "cubehelix less-angry rainbox" that was mentioned above. Look at the MODIFYCT documentation for more information.

And this, then, is how you can get arbitary colors for your plot. Figure out the red/green/blue values you want for each color. Make an array with these values, and then use MODIFYCT to store that array as a custom color table in your own color table file. Then read in that file using LOADCT when you make your graph.

Example figure: Below is a figure I made using Julian Freeman's data: