;+ ; NAME: ; SETPLOT ; ; PURPOSE: ; Set the plot environment for plots on screen or to PS or METAFILE. ; ; CATEGORY: ; Plotting tools. ; ; CALLING SEQUENCE: ; setplot, pltset [, pltpos] [, /small] [, /normal] [, /large] [, /longer] ; [, psfile=psfile] [, encaps=encaps] ; [, metafile=metafile] [, /close] [, /oldwin] ; ; REQUIRED INPUTS: ; pltset structure containing old and new device settings ; ; OPTIONAL INPUTS: ; pltpos position of the plot in device coordinates ; ; KEYWORDS: ; small make a small plot ; normal make a normal plot ; large make a large plot ; psfile name of the file for PS output ; encaps create EPS instead of PS files ; metafile name of the file for WINDOWS METAFILE output ; close close the currently active plot ; oldwin don't open a new window, use old one instead ; ; OUTPUTS: ; none ; ; DESCRIPTION AND EXAMPLE: ; This procedure sets the plot environment and device settings for plots ; on screen (the 'X' or 'WIN' devices), to POSTSCRIPT files or to WINDOWS ; METAFILES. Plots normally have a proportion of 4 to 3, meaning that ; the height is 3/4 of the width of the plot, except if the option LONGER ; is set where the ratio of height over width is 1/2. There are three ; sizes for plots: small, normal and large. The widths of the plot are ; defined for the different devices as follows: ; DEVICE: X/WIN POSTSCRIPT METAFILE ; [pixels] [cm] [cm] ; small : 400 8.8 24 ; normal: 800 12.0 36 ; large : 1200 18.0 56 ; longer: 1200 18.0 56 ; The sizes of the POSTSCRIPT plots correspond to the sizes of the ; figures allowed in A&A papers. If the keyword CLOSE is set then a ; currently open plot is closed, the original plotting and device ; settings are restored and the PLTSET variable is set to 'undefined'. ; The procedure checks whether the pltset variable is still defined from ; an earlier run of the programme. In this case the earlier plot is ; closed first. The procedure is correctly used in the following way: ; setplot, pltset, pltpos, ps='test' ; plot, sin(findgen(100)/10), position=pltpos, /device ; setplot, pltset, /close ; ; CALLED BY: ; midi_pltprp ; midi_adu2jy ; midi_pltopd ; midi_pltrad ; and others ; ; CALLING: ; none ; ; MODIFICATION HISTORY: ; 2008-10-14 Adapted from PAPSETPLT by Konrad R. Tristram ; 2009-02-26 Konrad R. Tristram: Added keyword ENCAPS for EPS output. ; 2010-07-22 Konrad R. Tristram: Added keyword OLDWIN. ; 2011-06-16 Konrad R. Tristram: Changed device keywords for PS output. ; 2012-11-01 Konrad R. Tristram: Adjust PS font size for !p.font=0. ; PRO SETPLOT, PLTSET, PLTPOS, SMALL=SMALL, NORMAL=NORMAL, LARGE=LARGE, $ LONGER=LONGER, PSFILE=PSFILE, ENCAPS=ENCAPS, METAFILE=METAFILE, $ CLOSE=CLOSE, OLDWIN=OLDWIN ; CHECK IF AT LEAST ONE PARAMETER HAS BEEN PASSED TO THE FUNCTION ;------------------------------------------------------------------------------- if ~ arg_present(pltset) then begin message, 'Syntax - SETPLOT, pltset [, pltpos, /small, /normal, ' + $ '/large, psfile=psfile]', /continue message, ' SETPLOT, pltset, /close', /continue return endif ; CHECK IF PROGRAMME IS CALLED FOR CLOSING A PLOT ;------------------------------------------------------------------------------- if keyword_set(close) then begin ; CLOSE THE PLOTTING DEVICE AND RESET THE PLOT PARAMETERS ;----------------------------------------------------------------------- if ((pltset.d_new eq 'PS') or $ (pltset.d_new eq 'METAFILE')) then device, /close set_plot, pltset.d_old !p = pltset.p tmpvar = temporary(pltset) ; OTHERWISE OPEN A NEW PLOT ;------------------------------------------------------------------------------- endif else begin ; DEFINE ADDITIONAL STRING FOR PS OUTPUT ;----------------------------------------------------------------------- psstri = 'systemdict /setdistillerparams known { ' + string(10b) + $ '<< /AutoFilterColorImages false /ColorImageFilter ' + $ string(10b) + '/FlateEncode >> setdistillerparams} if' ; IF PLTSET IS ALREADY CORRECTLY DEFINED THEN CLOSE THE PLOT STILL OPEN ;----------------------------------------------------------------------- if size(pltset, /type) eq 8 then begin tmpvar = ['D_OLD', 'P', 'D_NEW'] if array_equal(tag_names(pltset), tmpvar) then begin message, 'A plot is still seems to be open! ' + $ 'Closing it first.', /informa, /continue setplot, pltset, /close endif endif ; SAVE THE OLD PLOT SETTINGS IN THE PLTSET STRUCTURE ;----------------------------------------------------------------------- pltset = {d_old:!d.name, p:!p, d_new:!d.name} ; DEFINE SIZES FOR LARGE PLOTS, I.E. A&A TWO COLUMN FIGURES ;----------------------------------------------------------------------- if keyword_set(large) then begin ps_xsz = 18.0 ps_ysz = 13.5 ps_xof = 1.5 ps_yof = 7.9 ps_pos = [1400, 900, 17600, 13050] me_xsz = 56.0 me_ysz = 42.0 xw_xsz = 1200.0 xw_ysz = 900.0 xw_pos = [ 75, 50, 1175, 875] ; DEFINE SIZES FOR SMALL PLOTS, I.E. A&A SINGLE COLUMN FIGURES ;----------------------------------------------------------------------- endif else if keyword_set(small) then begin ps_xsz = 8.8 ps_ysz = 6.6 ps_xof = 6.0 ps_yof = 11.5 ps_pos = [1300, 850, 8400, 6175] me_xsz = 24.0 me_ysz = 18.0 xw_xsz = 400.0 xw_ysz = 300.0 xw_pos = [ 75, 50, 375, 275] ; DEFINE SIZES FOR LONG PLOTS, I.E. A&A TWO COLUMN FIGURE WITH 2/1 RATIO ;----------------------------------------------------------------------- endif else if keyword_set(longer) then begin ps_xsz = 18.0 ps_ysz = 9.0 ps_xof = 1.5 ps_yof = 10.5 ps_pos = [1400, 900, 17600, 8550] me_xsz = 56.0 me_ysz = 27.0 xw_xsz = 1200.0 xw_ysz = 600.0 xw_pos = [ 75, 50, 1175, 575] ; DEFINE SIZES FOR NORMAL PLOTS, I.E. A&A FIGURE WITH SIDECAPTION ;----------------------------------------------------------------------- endif else begin ps_xsz = 12.0 ps_ysz = 9.0 ps_xof = 4.5 ps_yof = 10.5 ps_pos = [1400, 900, 11600, 8550] me_xsz = 36.0 me_ysz = 27.0 me_pos = 38*[ 3.5, 2, 35.5, 26] xw_xsz = 800.0 xw_ysz = 600.0 xw_pos = [ 75, 50, 775, 575] endelse ; CHECK IF METAFILE OUTPUT DESIRED ON A UNIX MACHINE ;----------------------------------------------------------------------- if !version.os_family ne 'Windows' and keyword_set(metafile) then begin print, 'Cannot produce METAFILES on Unix systems.' print, 'Producing PS output instead.' psfile = metafile endif ; SET DEVICE PROPERTIES AND PLOT PROPERTIES FOR PS OUTPUT ;----------------------------------------------------------------------- if keyword_set(psfile) then begin set_plot, 'PS' device, file=psfile+'.ps', xsize=ps_xsz, ysize=ps_ysz, $ xoffset=ps_xof, yoffset=ps_yof, /portrait, $ bits_per_pixel=8, output=psstri, encapsulated=encaps, $ color=1 if !p.font eq 0 then !p.charsize=0.65 else !p.charsize=0.75 pltpos = ps_pos ; SET DEVICE PROPERTIES AND PLOT PROPERTIES FOR METAFILE OUTPUT ;----------------------------------------------------------------------- endif else if keyword_set(metafile) then begin set_plot, 'METAFILE' device, file=metafile+'.emf', set_font='Arial*18', $ xsize=me_xsz, ysize=me_ysz !p.font=0 !p.charsize=0.80 offset= 255 factor = -1 pltpos = me_pos ; OTHERWISE SET DEVICE PROPERTIES AND PLOT PROPERTIES FOR SCREEN OUTPUT ;----------------------------------------------------------------------- endif else begin if !version.os_family eq 'Windows' then set_plot, 'WIN' $ else set_plot, 'X' if keyword_set(oldwin) then newwin=0 else newwin=1 window, xsize=xw_xsz, ysize=xw_ysz, free=newwin device, decompose=0 !p.charsize=1.25 pltpos = xw_pos endelse ; SAVE THE CURRENT PLOTTING DEVICE IN THE PLTSET VARIABLE ;----------------------------------------------------------------------- pltset.d_new = !d.name endelse END