Producing Hardcopy and Image Output from GrADS

GrADS version 2.1 introduced the use of the Cairo library to handle all the graphics rendering, both for the interactive display in X windows and for the hardcopy and image outputs. The addition of Cairo means that GrADS can support drawing a wide variety of fonts, smoother looking anti-aliased lines, transparent colors, pattern filling, and more options for graphical output formats. These features provide an opportunity to create some beautifully polished publication-quality graphics.

Along with the introduction of the Cairo library came a major overhaul of the graphics code, which makes the rendering components more "pluggable" so that other options besides Cairo would be easier to implement in future versions. This overhaul necessitated some changes to the format of the GrADS metafile, which were long overdue but had been postponed in order to maintain backwards compatibility with all of the external metafile translators such as gxps, gxeps, gxtran, gv32, et al. The advent of version 2.1 means that those utilities are obsolete -- the metafile is now a metabuffer that exists only in memory during a GrADS session.

gxprint

The gxprint command was introduced in GrADS version 2.1. It replaces the printim and print commands from earlier versions, and it uses the Cairo library to produce hardcopy output in both image and vector graphic formats. The output is based on the current contents of the metabuffer, and it works in batch mode as well as interactive mode. The supported vector graphics formats are PS, EPS, PDF, and SVG; the only image format supported is PNG. If you desire an image format other than PNG, you must use an external utility such as the 'convert' command line tool from Image Magick. Please see the gxprint reference page for a complete list of all the options and how to use them.

The remainder of this doc page is only relevant for versions 2.0.2 and earlier...

 


Generating Image Files from GrADS

There are several GrADS commands that will convert the contents of the graphics window into an image file. The differences between them are the image formats they support and the way they are implemented in GrADS.

printim

The printim command was introduced in version 1.8. It uses the GD library to produce a PNG, GIF, or JPG formatted image file based on the current contents of the GrADS metabuffer, which is the stuff displayed in the graphics window, minus any widgets. printim will work in batch mode. Beginning with version 2.1, printim is an alias for gxprint.

outxwd

The outxwd command draws the contents of the graphics display window to a file in XWD (X window dump) format. It does not work in batch mode. It is obsolete beginning with GrADS version 2.1.

wi

The wi command is not included in version 1.9 or later.

Generating GrADS metafiles

N.B. This protocol is obsolete beginning with GrADS version 2.1.

1. Set-up the GrADS metafile

The first step in creating hardcopy image output is to invoke the enable print command -- this opens the output file and enables GrADS to direct image information to that file. If the file exists, it will be overwritten.

2. Display the image

The next step is to display the graphic that you want to print. When you have finished, issue the print command. GrADS copies the vector instructions used to create the current display into the output file in a GrADS metacode format. For multiple images in your metafile, use clear, create the new image, and then print again.

3. Close the GrADS metafile

There are three way to close the output file:
disable print
reinit
quit

Converting GrADS Metafiles to Postscript

N.B. This protocol is obsolete beginning with GrADS version 2.1. GrADS metacode files may be translated into postscript using the GrADS external utilities gxps and gxeps. Both utilities will prompt for input and output filenames, unless they are provided on the command line. The input filename should be the file created by the enable print command. The output filename can be anything, but a ".ps" extension is conventional. Any existing file with this name will be overwritten. Once the output file is created, you may print it using UNIX print commands. Please consult the references pages for gxps and gxeps to see all the command line arguments and options. Note that gxps and gxeps are not GrADS commands. They must be executed from the UNIX command line, or preceded by a ! and executed as a shell command from the GrADS command line.

Generating Postscript from within GrADS

N.B. This protocol is obsolete beginning with GrADS version 2.1. There is a shortcut for creating an encapsulated postscript (EPS) file directly from within a GrADS session: use the print command without invoking the enable print command first. This shortcut allows the user to skip the steps of creating the GrADS metafile and invoking the external utility gxeps. However, using this shortcut means there can only be one image per file, and none of the options available when invoking gxeps directly can be used.

Displaying GrADS Metafiles

N.B. This protocol is obsolete beginning with GrADS version 2.1. GrADS metacode files may be displayed using the GrADS external utility gxtran. The input filename should be the file created by the enable print command. If the GrADS metafile contains more than one image, gxtran will animate them. The animation can be automatic or controlled by the user with carriage returns. Please consult the gxtran reference page to see all the command line arguments and options.

Displaying GrADS Metafiles with Windows 95/NT

N.B. This protocol is obsolete beginning with GrADS version 2.1. The GrADS metafile Viewer (GV) allows you to view and manipulate GrADS graphics output files using Windows 95/NT. There are two files to download:

To open the metafile simply double click on a file listed in the File Manager or Explorer, drag and drop the file onto GV, or use the standard Open dialog box. GV assumes that default extension of GRADS metafiles is GMF. If your file includes more than one picture you can browse through pages using the keyboard keys (PageDown and PageUp) or the toolbar buttons.

Use the View commands and the View/Options dialog box to customize the image -- display it as black-and-white or color, change the line thickness, or clip and enlarge any part of the image. Use the right mouse button to access the most commonly used features.

There are two ways to save separate pages of a GRADS metafile as Windows Metafile (WMF): 1) use the File/Save Page As command, or 2) use the Edit/Copy command to copy the current page to the Windows Clipboard and then Edit/Paste it in your favorite Windows application that handles Windows Metafiles.

Use File/Print command to print a current document to any printer (you do not need a Postscript printer). Use File/Print Preview to display the active metafile as it would appear when printed.