Fanning Software Consulting

Using TeXtoIDL with Coyote Graphics Routines

Facebook RSS Google+

QUESTION: What is the best way to use TeXtoIDL with Coyote Graphics routines.

ANSWER: TeXtoIDL is a third-party software package written by Matthew Craig. It's purpose it to make it easy to use Greek letters and other special characters in title and axes text on graphical displays. It uses TeX control sequences that are simple and easy to remember, expecially if you are already familiar with LaTeX page formatting commands.

Although almost all the functionality of TeXtoIDL is duplicated in the cgSymbol command used for similar purposes in Coyote Graphics routines, many people find they still rely on TeXtoIDL for their formatting needs. To accommodate such people, it is now possible to embed TeXtoIDL control sequences directly in the text used in plot and axes titles and for other graphical purposes, exactly the way cgSymbol control sequences can be embedded in such text.

One big advantage of embedding TeXtoIDL sequences directly into the text is that it avoids the awkward problem of using TeXtoIDL control sequences in Coyote Graphics resizeable graphics windows. TeXtoIDL control sequences can now be used anywhere you would normally use Coyote Graphics routines.

To use a TeXtoIDL control sequence it is necessary to:

  1. Install the TeXtoIDL programs and make sure they are on your IDL path.
  2. Embed the TeXtoIDL control sequence into graphical text by prepending the control sequences with “\tex”.

Here is an example. Suppose you wanted to write “A goes to B, for B subset of C.” This involves a right arrow symbol and a subset symbol that are not currently in cgSymbol, so you want to use TeXtoIDL to create those symbols. You would construct and display the string like this.

   cgDisplay, 500, 100
   aString = 'A $\tex\rightarrow$ B, B $\tex\subset$ C'
   cgText, 0.5, 0.5, Align=0.5, /Normal, Charsize=3.0, aString
Using TeXtoIDL control sequences in Coyote Graphics routines.
Using TeXtoIDL control sequences in Coyote Graphics routines.
 

Naturally, such routines can also be used in PostScript output.

   cgPS_Open, 'textoidl_2.ps'
   cgDisplay, 500, 100
   aString = 'A $\tex\rightarrow$ B, B $\tex\subset$ C'
   cgText, 0.5, 0.5, Align=0.5, /Normal, Charsize=3.0, aString
   cgPS_Close, /PNG, Width=500
The same code produces the same results in PostScript.
The same code produces the same results in PostScript.
 

You can use this string in any plot or axis title, or any other graphical text, in a Coyote Graphics routine.

   cgPlot, cgDemoData(1), XTitle=aString

You can even use it in the resizeable graphics window, cgWindow.

  cgPlot, cgDemoData(1), XTitle=aString, /Window

It will produce the correct PostScript version automatically.

   cgControl, Output='textoidl_3.png', IM_Width=500
The PostScript output from a cgWindow with TeXtoIDL control sequences.
The PostScript output from a cgWindow with TeXtoIDL control sequences.
 

You will need an to update your Coyote Library routines to use this new functionality.

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

Written: 24 November 2012