Fanning Software Consulting

Why Friggin' PostScript Landscape Mode?

Facebook RSS Google+

QUESTION: Look, why is it that every time I create PostScript output from a Coyote Graphics routine it is in friggin' Landscape mode!? Can't something be done about this?

ANSWER: Sure something can be done. Coyote Graphics routines can create PostScript output in any God-forsaken way you want to create it. You simply have to tell the programs what you want. In the absence of information, Coyote Graphics routines try to create the largest "window" possible on a PostScript page that maintains the aspect ratio of the current graphics window. The "current graphics window" is either the current graphics window on your display, or if there are no windows on the display, the one that would be created if you opened a window on the display. In other words, the default window. It does this so that what you see in your PostScript output resembles as closely as possible what you see in your graphics window.

I don't know if you have noticed this, but most graphics windows you open are in a Landscape orientation. This is the reason for what you perceive as the Coyote Graphics bias for Landscape mode output. If you simply changed your default graphics window size to a Portrait aspect ratio, you will soon be yelling at me for making all Coyote Graphics routines produce Portrait mode output.

On a Windows machine, you can change your default graphics window size like this.

   Pref_Set, 'IDL_GR_WIN_HEIGHT', 640, 'IDL_GR_WIN_WIDTH', 512, /Commit

On any other machine, you can change your default graphics window size like this.

   Pref_Set, 'IDL_GR_X_HEIGHT', 640, 'IDL_GR_X_WIDTH', 512, /Commit

The preferences will take effect the next time you start IDL.

Of course, you can also make a temporary window, which will have the same effect, but not change the default preferences.

   cgDisplay, 512, 640

I deliberately used cgDisplay to create the window in this case, because cgDisplay has magic properties in PostScript files. It can be used, obviously, to create a graphics window. But, you can't create graphics windows in PostScript files (a Window command, for example, causes an error). What cgDisplay does is make the "window" in a PostScript file have an aspect ratio that is identical to the window that would have been created on the display. So, putting this command in a graphics program would cause the PostScript output to have a Portrait orientation.

If you make a PostScript file from within a resizeable cgWindow, the orientation of the PostScript file matches the aspect ratio of the cgWindow. Give that window a Portrait orientation (either when you create it or by resizing it interactively), and the PostScript output will be in Portrait mode.

Finally, cgPS_Open, which is what Coyote Graphics routines use to set up and configure the PostScript device (see the Coyote Plot Gallery for examples), is infinitely configurable. With it, you can create the PostScript file in whatever fashion you like. The only "trick" is to be sure you set the NoMatch keyword to turn off its proclivity to match the aspect ratio of the current graphics window.

  cgPS_Open, 'myfile.ps', /NoMatch, XSize=5, YSize=6, Landscape=0, XOffset=1.75, YOffset=2.5, /Inches
  cgPlot, cgDemoData(1)
  cgPS_Close

It is often easier, if you are going to modify the PostScript output, to do it interactively.

   cgPS_Open, 'myfile.ps', /NoMatch, /Gui, Cancel=cancelled
   IF ~cancelled THEN BEGIN
      cgPlot, cgDemoData(1)
      cgPS_Close
   ENDIF

When you set the GUI keyword, you will see the PostScript configuration interface shown in the figure below.

The PostScript device is nearly infinitely configurable from cgPS_Open.
The PostScript device is nearly infinitely configurable from cgPS_Open.
 

As always, if your programs don't act like this, please update your Coyote Library to the latest version.

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

Written: 20 February 2013