# R script to make a ship series figure # We're going to use grid graphics library(grid) library(lattice) library(maps) # put the output in a PS file #postscript(file="ship_series.ps",pointsize=14) png(file="ship_series.png",width=900,height=600,pointsize=14) # Base the structure on a graph of surface data Series <- read.table("../series_files/Aurora",na.strings = 'Na') # Load the plotting functions source("series_utility_fns.R") xrange=xaxis.label.to.at(c("1911/09/25","1911/11/05")) # Arrange the viewports for the map and the three series plots pushViewport(viewport(width=0.5,height=0.5,x=0,y=0.5, just=c("left","bottom"),name="vp_map")) upViewport(0) pushViewport(viewport(width=0.5,height=0.5,x=0.5,y=0.5, just=c("left","bottom"),name="vp_slp")) upViewport(0) pushViewport(viewport(width=0.5,height=0.5,x=0.5,y=0.0, just=c("left","bottom"),name="vp_temperature")) upViewport(0) pushViewport(viewport(width=0.5,height=0.5,x=0.0,y=0.0, just=c("left","bottom"),name="vp_ice")) upViewport(0) # Draw the map downViewport("vp_map") print(sr.map(Series$V11,Series$V12,Series$V2,col=4,cex=3, time_range=xrange), newpage=F,prefix="map1") upViewport() # Draw the time-series plots downViewport("vp_slp") SeriesPlot(Series$V2,Series$V9-Series$V10,xaxis=F,xrange=xrange, ylabel="SLP anomaly (hPa)") upViewport() downViewport("vp_temperature") SeriesPlot(Series$V2,Series$V5-Series$V6,ylabel="SST anomaly (C)", xrange=xrange, xaxis=T,xlabel="Date",ygp=gpar(col=rgb(1,0,0,1)), y2Data=Series$V7-Series$V8,y2axis=T,y2label="AT anomaly (C)") upViewport() downViewport("vp_ice") SeriesPlot(Series$V2,Series$V3,xaxis=T,xlabel="Date",xrange=xrange, yaxis=T,ylabel="Ship speed (m/s)", y2Data=Series$V4,y2axis=T,y2label="Ice coverage (fraction)") upViewport() # Exit R q('no')