About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 23 February 2009

How do I create a hardcopy version of my plot? [Updated]


The print_window() (S-Lang, Python help) routine creates a hardcopy version of the current window. It can be called with no, one, or two arguments:

# Python
  print_window()
  print_window("fig")
  print_window("fig", ["format","png"])
  print_window("fig", ["fittopage",1,"pagesize","letter","clobber",1])
% S-Lang
  print_window;
  print_window("fig");
  print_window("fig", {"format","png"});
  print_window("fig", {"fittopage",1,"pagesize","letter","clobber",1})

If called with no arguments the plot is sent as a postscript file to the default printer, otherwise the first argument gives the start of the file name (the suffix is determined from the output format). The default output format (as given by the export.format preference setting) is "ps", so the second example creates a postscript format file called fig.ps. The third example shows how to override the format setting to create a PNG format file called fig.png. The following formats are available: ps, eps, pdf, png, and jpg.

The last example creates fig.ps, overwriting it if it already exists, and makes the output US letter sized (the aspect ratio of the on-screen plot will be retained since the default value for export.keepaspect is true).

The print_window() routine can be called more than once for the same visualization.

Using a print dialog (GUI) to control the output

[New] CIAO 4.1 has added the ability to control the output of print_window - such as the location of the output, the format, and page size - using a GUI. This GUI is created when print_window is called if the export.printdialog setting is true.

This setting can be changed globally - so that all print_window calls will use the GUI - by saying

# Python
  set_preference("export.printdialog", "true")

% S-Lang
  set_preference("export.printdialog", "true");

or just for an individual call by saying

# Python
  print_window("plot", ["printdialog", True])

% S-Lang
  print_window("plot", {"printdialog", 1});


Last modified: 23 February 2009


The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.