X = FltArr(40)
Y = FltArr(40)
names = StrArr(2)
symbols = FltArr(2,12)
array = FltArr(2,40)
The names will be read in from the data file,
however, they were preformatted for use with disspla. I re-interpreted
them here in the program which produces the graph.
namex = '!7D!6!Dr!NS!9%!6/ (J K!E-1!N mol!E-1!N)'
namey = '!7D!6!Dr!NH!9%!6/ (J K!E-1!N mol!E-1!N)'
The errors associated with the data had the high
and low values generated already. Here I manually calculated what
the +/- values were for each data point.
errX = [2, 3, 1.4, 1.4]
errY = [0.6, 0.7, 0.4, 0.4]
The data file is opened here.
OpenR, lun, 'example', /Get_Lun
Point_Lun, lun, 0
The data file is read here. The entire
file is read and the values placed into the variables listed after "lun."
ReadF, lun, nsets, names, nscl, symbols, array
The FltArr named "array" contains all of the
two columns of data. X is being set to the first column of data,
whereas Y contains the second column of data.
X = array(0,*)
Y = array(1,*)
Free_Lun, lun
Arrays X & Y are reformed so they are changed
from column vectors into row vectors.
X = Reform(X)
Y = Reform(Y)
The two columns of data that were read into "array"
then transfered into 2 one-dimensional arrays, X and Y, contain various
different types of data. It turns out that only the first 4 numbers
are points that will be plotted with circles. Then, "-1"s were used
to separate the data into sets. Those -1s are skipped and not read.
The 4 points, subscripted from 5 to 8 are plotted by plusses and are read
into their own array. Finally, two lines are drawn with the final
set of data. Note the really convenient syntax where you can read
portions of an existing array without using a loop!
CircX = X(0:3)
CircY = Y(0:3)
PlusX = X(5:8)
PlusY = Y(5:8)
LineX1 = X(34:35)
LineY1 = Y(34:35)
LineX2 = X(37:38)
LineY2 = Y(37:38)
I modified the existing code to do something a
little bit different. This shows you the opening to a myriad of minor
variations.
Print, 'Device Menu:'
Print, '1 = Tektronix 4014'
Print, '2 = Printer'
Print, '3 = Postscript file and potential printing'
Print, 'Which device do you want?'
Read, whichdevice
CASE whichdevice OF There
are 3 choices, so I'm using a "CASE" statement
'1': Begin
Set_Plot, 'TEK'
DEVICE, /TEK4014
End
'2': Begin
Set_Plot, 'printer' ;Use the DIALOG_PRINTERSETUP
function to define parameters
End
'3': Begin
Set_Plot, 'PS'
DEVICE, FILENAME = 'ertest.ps'
DEVICE, /INCHES, XSIZE = 7.5, YSIZE
= 8, $
XOffset = 0, YOffset = 0
For the postscript file I am changing the axis
titles to use postscript fonts
!p.font=0
namex = '!9D!18!Dr!NS!Eo!N!18/ (J
K!E-1!N mol!E-1!N!18)'
namey = '!9D!18!Dr!NH!Eo!N!18/ (J
K!E-1!N mol!E-1!N!18)'
End
Else: Print, 'Not a device'
EndCase
If (whichdevice EQ 1) Then Begin
Set_Plot, 'TEK'
DEVICE, /TEK4014
EndIf Else Begin
Set_Plot, 'PS'
Output goes to a postscript
file
DEVICE, FILENAME = 'xy.ps'
Name the postscript file ending with .ps
DEVICE, /INCHES, XSIZE = 7.5, YSIZE = 8, $
XOffset = 0.002, YOffset = 0.05
EndElse
!p.charsize=2
Make text twice the default size
A = FIndGen(16) * (!PI*2/10.) Generate
the symbol for a circle
UserSym, cos(A), sin(A)
Plot, CircX, CircY, XTITLE = namex, YTITLE = namey, $
XStyle = 1, XRange=[-40,10], $
YStyle = 1, YRange=[-20,-8], Max_Value=-8, $
SymSize=1.5, PSym = 8
OPlot, PlusX, PlusY, PSym = 1,
OPlot, LineX1, LineY1, PSym = 0,
OPlot, LineX2, LineY2, PSym = 0, LineStyle=1 Here
the linestyle is changed to dotted.
xyoerr, X, errX, Y, errY
Call the special function written to plot both
x and y error bars
If you put a comma after errY, you can add a
number for the LineStyle and the Thickness
of the line, but these are optional. (e.g., xyoerr, X, errX, Y, errY,
2, 4). The defaults for not describing them are a solid line of normal
thickness.
If (whichdevice EQ 2) Then Begin You
need to close the document for the graph to actually go to the printer
DEVICE, /Close_Document
EndIf
Now that the PostScript file has been opened,
you need to close the file. Then you are prompted as to whether or
not you want to print. Any other key pressed besides y will not result
in printing. (eg. "n" or "1" will both not print).
If (whichdevice EQ 3) Then Begin
DEVICE, /Close_File
toprint = ''
Print, 'Y or N'
Print, 'Do you want to print?'
Read, toprint
If (STRUPCASE(toprint) EQ 'Y') Then Begin
Spawn, 'lpr xy.ps'
Print, 'Done printing'
EndIf
EndIf
END