PRO PS_Create_1D, x, y, q, dx, dy,  $
	LINESTYLE = lineStyle, THICK = thick, $
	OFFSET = offset, COLOR = color,  $
	XRANGE = xRange, YRANGE = yRange, $
	LENGTH = length, RESET = reset, $
	FILENAME = fileName, XPOS = xPos, $
	YPOS = yPos, WIDTH = width, HEIGHT = height, $
 	LANDSCAPE = landscape, MDISP = mdisp, $
	LOGO = logo, SIXEL = sixel

;+
; NAME:
;	PS_Create_1D
;
; PURPOSE:
;	Redirects the plot output of the procedure "Data_Display"
;	to a postscript file.
;
; CATEGORY:
;	1D
;
; CALLING SEQUENCE:
;	PS_Create_1D, [ x, y [, qualifier [, dx, dy ] ] ]
;
; INPUTS:
;	x: the x-values, a 2D array. If not present, the x range is set 
;		from 0 to the number of elements minus 1.
;	y: the y-values also real 2D array, each line is a plot.
;	q: the qualifiers for each value to plot. The number follows
;		the definition of the !psym system variable.
;		It is a 2D integer array
;	dx, dy; the errors in x- and y-direction. If the error bars 
;		are symmetrical, then "dx" and "dy" are
;		2D real arrays. If they are not symmetrical,
;		then dx(*,*,0) and dx(*,*,1) contain the errors
;		left and right, respectively and dy(*,*,0) and
;		 dy(*,*,1) contain the errors up and down,
;		respectively.
;
; KEYWORDS:
;	LINESTYLE: for each plot a value corresponding to the
;		!p.linestyle system variable. A 1D array.
;	THICK: The line thickness, corresponding to the !p.thick
;		system variable. A 1D real array.
;	OFFSET: An y-offset added to all y-values of a plot,
;		a 1D real array.
;	COLOR: a color for each plot, 1D integer array
;	RESET: If present, the scaling is done automatically,
;		otherwise, the last one is used, unless the
;		system variables !x/y.range are [0,0]
;	XPOS, YPOS: The position of the lower left corner
;		of the plot. If not specified, the have both
;		the value 1 (units in centimeters).
;	XSIZE, YSIZE: The width and height of the plot
;	FILENAME: The file name. If not specified,
;		the file name will be the first ten chars of the
;		variable "!p.title"
;	LANDSCAPE: If present the file is printed in landscape 
;		 mode
; 	LOGO: If set, writes "institute of astronomy' on the 
;		bottom of the page.
;	SIXEL: If set, the file is in SIXEL format (for printing
;		on the ln03 printer).
; SIDE EFFECT:
;	Creates a file. The default name is "mdisp.ps", if not 
;	precised in the FILENAME 
;	keyword. If already present, the old file is deleted.
;
;MODIFICATION HISTORY:
; 	Created in June 1991 by A.Csillaghy
;	Modified for sixel devices and wave 4, 
;		Nov. 92, ETHZ, A.Cs
;       Changed the default filename mdisp.ps to ragview.ps 
;               csillag@ssl.berkeley.edu, May 16, 1998
;-

  On_Error, 2

  saveP = !p & saveX = !x & saveY = !y
  colorOn = 0
  IF Keyword_Set( MDISP ) THEN BEGIN
    GetPSSizes, xPos, yPos, xSize, ySize, landscape, colorOn, encaps,logo
    GetTitles, title, xTitle, yTitle, subTitle
  ENDIF ELSE BEGIN
    IF NOT Keyword_Set(XPOS) THEN xPos = 1.
    IF NOT Keyword_Set(YPOS) THEN yPos = 5.
    IF NOT Keyword_Set(XSIZE) THEN xSize = 18.
    IF NOT Keyword_Set(YSIZE) THEN ySize = 14.
    IF NOT Keyword_Set(LANDSCAPE) THEN landscape = 0
    IF NOT Keyword_Set(LOGO) THEN logo = 0
    IF NOT Keyword_Set(COLOR) THEN BEGIN
      color = 0
      colorOn = 0
    ENDIF
  ENDELSE
    
  IF NOT Keyword_Set(FILENAME) THEN filename = 'ragview'

  oldDevice = !d.name
  isSixel =   Keyword_Set( SIXEL )

  IF isSixel THEN BEGIN
    Set_Plot,'SIXEL' 
    factor = 2
    extension = '.sxl'
    !p.font = -1 & !p.charsize = 0.8
    !p.charthick = factor*1.5
    !p.thick = factor*1.5
    !x.thick = factor & !y.thick = factor
    Device, RESOLUTION = [150*factor,150*factor]
  ENDIF ELSE  BEGIN
    Set_Plot,'PS'
    extension = '.ps'
  ENDELSE
  
    Device, FILENAME = fileName + extension

    IF landscape THEN Device, /LANDSCAPE $
    ELSE Device, /PORTRAIT
  
    Device, XOFFSET = xPos, YOFFSET = yPos+21*landscape, $
	XSIZE = xSize, YSIZE = ySize

    IF NOT isSixel THEN Device, /TIMES 

    IF colorOn AND NOT isSixel THEN Device, /COLOR

  IF encaps THEN Device, /ENCAPSULATED

  IF Keyword_Set( MDISP )  THEN Data_Display, /MDISP, $
	/NOCOLOR $
  ELSE  Data_Display, x, y, q, dx, dy,  $
	LINESTYLE = lineStyle, THICK = thick, $
	OFFSET = offset, COLOR = color,  $
	XRANGE = xRange, YRANGE = yRange, $
	LENGTH = length, RESET = reset, $
	TITLE = title, XTITLE = xTitle, YTITLE = yTitle, $
	SUBTITLE = subTitle

  IF logo NE 0 THEN BEGIN
    !p.font = 0
    IF NOT isSixel THEN Device, /HELVETICA, /OBLIQUE
    XYOuts, 0.6, -0.05, 'Institute of Astronomy, ETH Zurich', $
	 /NORMAL
  ENDIF

     Device, /CLOSE
     plotNr = 1

  Set_Plot, oldDevice

  !p = saveP & !x = saveX & !y = saveY

END ; create postscript file
