saving postscript file in idl

by user4437416   Last Updated September 05, 2016 08:09 AM

I am using the introductory book by Bowman to learn plotting in IDL. I am using an example procedure by Bowman which should have the effect of saving a a plot to a ps file, but it is not working. Here is the code:

PRO LINEGRAPH3, PS = ps

;+
; Name:
;      LINEGRAPH3
; Purpose:
;      Plots a simple line graph and optionally saves a Postscript file. 
; Calling sequence:
;      LINEGRAPH3
; Inputs:
;      None.
; Output:
;      Line graph and optional Postscript file.
; Keywords:
;      PS : If set, save the Postscript output to linegraph3.ps.
; Author and history:
;      Kenneth P. Bowman, 2004.
;-

COMPILE_OPT IDL2                                             ;Set compiler options

xsize  = 4.0                                                 ;Width of graphic
ysize  = 4.0                                                 ;Height of graphic
dpi    = 100                                                 ;Screen dots per inch
margin = 0.1                                                 ;Margins of graphic

IF KEYWORD_SET(ps) THEN BEGIN
   print, 'keyword_set'
   psfile = !Bowman + 'ps/linegraph3.ps'                     ;Postscript file name
   PS_ON, FILENAME = psfile, PAGE_SIZE = [xsize, ysize], $   ;Set device to Postscript
      MARGIN = margin, /INCHES
ENDIF ELSE BEGIN
   print, 'keyword_not_set'
   WINDOW, XSIZE = dpi*xsize, YSIZE = dpi*ysize              ;Open graphics window
ENDELSE

x = FINDGEN(11)                                              ;Abscissa
y = SQRT(x)                                                  ;Ordinate
PLOT, x, y                                                   ;Draw line graph
OPLOT, x, 2.0*y                                              ;Overplot second line

IF KEYWORD_SET(ps) THEN PS_OFF                               ;End Postscript output

END

This does not save a postscript file. Instead, the plot shows up on the screen with the printed text 'keyword_not_set'. Because the keyword is indeed set to ps, this should not happen and i should get a saved file. What is the problem with this?



Related Questions



Graphics2D text and point position

Updated April 26, 2018 15:22 PM