# Stochastic Calculus, Courant Institute, NYU, Fall 2012 # Getting started with R, assignment 1a, an array and plot demo # (your name and email here) # The commands to make the plot. # They are in a separate file so they can be used to make the same plot ... # ... in different places (a terminal window and a .pdf file). plot( xp, lp, # plot xp vs lp ylim = yMinMax, # range of the y axis main = title, # overall plot title sub = PlotInfo, # subtitle has info on the plot xlab = xlabel, # label for the x axis ylab = ylabel, # label for the y axis type = 'l', # draw a line (not just symbols) lty = 1, # draw a solid line (not dashed or dotted) col = 'black' ) # a black line lines( xp, cp, # plot xp vs cp on the same plot type = 'l', # draw a line (not just symbols) lty = 2, # draw a dashed line col = 'blue' ) # a blue line lines( ix, iy, # add the intersection points type = 'p', # give them as points, not a connected line pch = 12, # use symbol number 12, which is a box col = 'red' ) # a red box grid() # draw grid lines on the graph so it's easy to read # Create a legend saying what is in the graph labels = c("cubic", "linear", "intersections") # a list of three strings legend( xMin + .5, yMinMax[2] - .8, # Where to put the legend box labels, # list of labesls for the lines col = c("blue", "black", "red"), # corresponding colors lty = c( 2 , 1 , 0 ), # line types. 2 = dashed, 0 = no line pch = c( NA , NA , 12 ) ) # characters. NA means "none"