Re: Routine is not defined for current graphics device. [message #45817] |
Thu, 13 October 2005 13:10 |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
Maher wrote:
> Hi, I use this little code to view the output on the screen directly or
> save it as a PS:
>
> plotps =0 ;1 for postscript
> psfilename = 'chicken.ps' ; name of postscript file
> if (plotps) then begin
> set_plot, 'PS' ; plot results to postscript file
> device, /color, filename = psfilename,ysize=15, $
> yoffset=1.0,bits_per_pixel=8,/iso,/helvetica,/portrait
> !p.font=0
> endif
> if (plotps eq 0) then window,1, ysize=650,xsize=800
> linethick = 1.0
> sizeofchar = 1.25
> thickofchar = 1.0
> !p.charsize = 1.25
>
> Now, if the output is PS, then I change the plotps flag to 0 for direct
> view, I get this error:
> % WINDOW: Routine is not defined for current graphics device.
>
> I have to close IDL and run it again to run with a plotps =0 flag.
>
> Any hlep is highly appreciated.
> Thank you
> Maher
>
Once you change the plot device (set_plot), it will stay like that until
you change it back (or restart IDL, where the default device is used).
The usual procedure for using the PS device is
old_plot = !d.name ;; stores the current device in a variable,
;; either 'win' or 'x' depending on your platform
set_plot, 'ps'
device, ... ;; configure PS device
plot, ... ;; plot whatever you want
device, /close
set_plot, old_plot ;; set graphics device back to default,
;; 'win' or 'x'
Often people also store and later restore !p.font and other graphics
device settings.
Benjamin
|
|
|