Skip to content

IDL Color Plot Procedure Problems and Tentative Solutions

In our galactic magnetic field project,  color plots seem to fail sporadically, leaving plots with blank places where there should be colored symbols or lines.  Very frustrating!  I am finding this with AO_ATNF_Pulsars_RM_Sag_Region1a.pro

So I tried manually to play around with this from the IDL command line, basically trying to duplicate it.  Note that the above program uses cgcolor multiple times to set up definitions of say red to then be used in plot procedure (without quotes, e.g. plot,x,y,red ). Note comments in above
say we needed to use cgcolor because regular idl colors
were not working. Note all this is with plot procedure, and
newer plot function may not have any of these probs! New programs should use the latter.

From command line, if I do the following:

x=findgen(10)
y=findgen(10)
set_plot,’ps’  (I think needs it only once)
device,filename=’help.ps’ (puts the file in home directory)
Red =cgColor(“Red”, !D.Table_Size-4)  (stolen from pgm, and cgcolor is a coyote routine [there are such calls for every color used])
plot, x, y, color=red (makes every bit of plot red)
device,/close

The above made a red plot in the file ~help.ps .

And then FWIW when I reran the AO_ATNF . . . Sag..1a.pro,
the two plots’ colors were there. I’m not saying cause and
effect, but at least in this case a rerun after above jimmying
brought the colors back.  I am guessing that somehow I
am not properly totally initializing colors when I run the
program, so if something color-related  is left in a funny
state by a previous run, then the next program run does
not automatically fix it.

Coyote has some suggestions at
http://www.idlcoyote.com/color_tips/redps.html   ,
including:

    Set_Plot, 'PS'    
Device, DECOMPOSED=1, COLOR=1, BITS_PER_PIXEL=8, filename='help.ps' 
(Joel added the filename part.)

and he claims that all the above are needed for color to
work, so maybe the program’s lack of such a full Device command is the problem. However the above advice is old and I’m not
sure if today’s idl might need say 24 bits per pixel???? But
the color=1 command sounds like it is turning on color!  Decomposed=1 turns on decomposed colors which I think means R,G,B are expressed separately. That is documented here and there but I’m not sure if our cgcolor routines expect that value, so, be careful!

Sorry I don’t have the definitive fix but hopefully the user can create a workaround with some subset of above, if she suddenly loses color on plots that were colored in previous program runs!

–Joel

Published inIDL hints

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *