#
# an example of how to make a simple plot with pgplot via ppgplot
#
# On Durham ITS (Vega), first "star.init" to set up paths, etc,
# then "python jor_plot.py" to  run
#
import ppgplot, numpy       # load modules required

datafile=open('jor_comp.dat','r')       # open data file
lines = datafile.readlines()            # read in lines
datafile.close()                        # close data file

# load columns into python lists
galname=[]              # set up null list for galaxy name
x_arr=[]                # set up null list for x axis values
y_arr=[]                # set up null list for y axis values
for k in lines:                 #  loop thru "lines" and put values in a list
    word = k.split()            #  split line into words
    galname.append(word[0])     #  galaxy name is 1st column
    jor_r = float(word[1])      #  Jor's radius is 2nd column
    x_arr.append(jor_r)         #  append to x_arr list
    jrl_r = float(word[2])      #  JRL's radius is 3th column
    y_arr.append(jrl_r)         #  append to y_arr list

xx=numpy.array(x_arr,dtype='f')   # convert python list to a numpy array
yy=numpy.array(y_arr,dtype='f')   # convert python list to a numpy array

# plot using pgplot calls in python (ppgplot)
# see http://www.starlink.rl.ac.uk/star/docs/sun15.htx/node14.html

ppgplot.pgopen('comp.ps/vcps')                         # select device/filename
                                                       # i.e. comp.ps
ppgplot.pgvsiz(1.0,6.0,1.0,6.0)                        # select physical size
ppgplot.pgslw(2)                                       # increase line weight
ppgplot.pgswin(0.0,2.0,0.0,2.0)                        # set world coordinates
ppgplot.pgbox('bcnts',0.0,0,'bcnvts',0.0,0)            # set axis parameters
ppgplot.pglab('Jorgensen log_r_h','JRL log_r_h ',' ')  # set axis labels
ppgplot.pgpt(xx,yy,16)                                 # plot points, symbol=16
ppgplot.pgsls(2)                                       # set dash line style
ppgplot.pgmove(0.0,0.0)                                # move to 'pen' position
ppgplot.pgdraw(2.0,2.0)                                # draw to 'pen position
ppgplot.pgclos()                                       # close device
