Specific Sizing of PostScript Output
QUESTION: I am making some IDL figures for a journal article. The journal specifies that PostScript files should not exceed 24.5 x 17.0 centimeters in size. When I create my PostScript output, though, it appears my files are created at about 27.9 x 21.6 centimeters in size. How can I create a PostScript file of the correct size using your Coyote Graphics routines?
Here is the test program I'm using.
PRO Test cgDisplay cgPlot, cgDemodata(1), Color='RED', PSym=-16, SymColor='BLUE' END
I create the PostScript file like this.
cgPS_Open, 'test.ps' Test cgPS_Close
ANSWER: The first problem you have is the cgDisplay command to create a graphics window in your test program. I like to think cgDisplay has "magical" properties in a PostScript file. Most people are not concerned with the size of the PostScript output, of course, they just expect to create a PostScript file. Usually so the file can be converted to a high resolution raster file. To accommodate these people, cgDisplay works in PostScript to create a Postscript "window" that has the same aspect ratio as the current graphics display window. This is convenient because then the graphic you just displayed on your graphics device now looks pretty much identical when it is rendered in PostScript. The downside, of course, is that the "window" that is created may not have the size your really want in your PostScript output.
To keep this from happening, you should remove the cgDisplay command from your test file, or at least protect it. For example, you might write your test program like this.
PRO Test IF !D.Name NE 'PS' THEN cgDisplay cgPlot, cgDemodata(1), Color='RED', PSym=-16, SymColor='BLUE' END
Suppose you want to create a PostScript file that has a size of 18 x 12 centimeters in order to stay within your self-imposed size limits. If you have a version of the Coyote Library created after 10 February 2014, you can create such a file using the size and offset keywords you can pass to cgPS_Open. (These are really keywords to cgPS_Config, and are just passed along by cgPS_Open.) But, what values should you use for these keywords, especially if you want to center the output on the PostScript page?
The easiest way to find out is to just open cgPS_Config and arrange the plot yourself. Call the program like this, initially. To work in units of centimeters, the Inches keyword needs to be turned off.
void = cgPS_Config(XSize=18, YSize=12, Inches=0)
You will see a window similar to the one in the figure below. Note that the "window" (the yellow portion of the plot window) is not centered in the larger green "page". Also note the XOffset is set to 1.27 cm and the YOffset is set to 6.35 cm.
|The initial Postscript configuration result.|
To center the "window" in the "page", simply click your middle mouse button anywhere inside the graphics window on the right. The plot is centered and the XOffset and YOffset values are now updated to 1.79 and 7.97, respectively. These are the numbers you want to use in the code below. Hit either the Cancel or Accept button to dismiss the dialog.
|The Postscript configuration dialog after centering the plot window.|
To create your PostScript file, then, you issue a cgPS_Open command as is the code below. Note that cgPS_Open always tries to "match" the aspect ratio of the current graphics window, unless instructed otherwise. Use the NoMatch keyword to turn this feature off. I've set the GUI keyword in this case, just so you can see what is happening. In practice, you probably don't want to use it.
cgPS_Open, 'test.ps', XSize=18, YSize=12, XOffset=1.79, YOffset=6.35, /NoMatch, /GUI Test cgPS_Close
This creates a PostScript file with a graphic output that is exactly 18 x 12 centimeters.
Version of IDL used to prepare this article: IDL 8.2.3.