Fanning Software Consulting

Incorrect Symbols in cgWindow

QUESTION: I am trying to use Coyote Graphics routines to create a plot with two lines using different symbols, a filled circle and a filled square, to distingish them. I have no trouble doing this if I put the plot in a normal IDL graphics window like this.

    cgPlot, Indgen(10)*2, PSym=-SymCat(15), Color='blue', SymSize=2
    cgPlot, Indgen(10), PSym=-SymCat(16), Color='red', SymSize=2, /Overplot
No problem using different symbols in a normal IDL graphics window.
There is no problem using different symbols in a normal IDL graphics window.
 

But, if I try to put this plot into a resizeable graphics window, like this, the symbols always come out the same!

    cgPlot, Indgen(10)*2, PSym=-SymCat(15), Color='blue', SymSize=2, /Window
    cgPlot, Indgen(10), PSym=-SymCat(16), Color='red', SymSize=2, /Overplot, /AddCmd
The symbols are the same in a resizeable graphics window.
The symbols are the same in a resizeable graphics window!
 

Am I doing something wrong!?

ANSWER: This is another manifestation of the fact that keyword and parameter values in resizeable graphics windows are static and not dynamic. When you use SymCat to specify the symbol type it returns the value 8 in both cases, which means use the one and only one symbol that is currently defined in this IDL session. This value, 8, is hardcoded as the keyword value. So the symbols in your window always use the symbol that is the last one defined.

Fortunately, there is an easy way out of your dilemma. Don't use SymCat to specify your symbol. Rather, let the cgPlot command do it for you internally! Here are the commands you should be using, both in the normal IDL graphics window and in a resizeable graphics window.

    cgPlot, Indgen(10)*2, PSym=-15, Color='blue', SymSize=2, /Window
    cgPlot, Indgen(10), PSym=-16, Color='red', SymSize=2, /Overplot, /AddCmd

As you can see in the figure below, this works perfectly.

Let cgPlot specify the SymCat symbol itself.
Let cgPlot specify the SymCat symbol itself.
 

Program Update

It turned out that about two minutes after I posted this article on my web page there was a report on the IDL newsgroup of some very strange behavior with the NASA Astronomy Library routine AL_Legend. After we investigated, we discovered that it, too, suffered from this problem of not allowing cgPlotS to call SymCat inside the program itself. Wayne Landsman very quickly responded with an updated version of AL_Legend, which you should download from the NASA web site. Be sure you have a version updated on or after December 14, 2011.

Version of IDL used to prepare this article: IDL 8.1.

Written: 13 December 2011