;********************************************* ; box_5.ncl ; ; Concepts illustrated: ; - Drawing box plots ; - Using a box plot to show the the median, minimum/maximum value, and the 25th/75th percentiles of two timeseries ; - Adding text to a box plot ; - Sorting data ; - Setting the mininum/maximum value of the Y axis in a box plot ; - Generating dummy data using "random_normal" ; ;********************************************* load "\$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "\$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "\$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" load "\$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl" ;********************************************* begin nor = random_normal(292,15,(/125/)) ; set up data dimt = dimsizes(nor) x25 = round(.25*dimt,3)-1 ; -1 to account for NCL indexing starting x75 = round(.75*dimt,3)-1 ; at 0 nor2 = random_normal(295,14,(/125/)) qsort(nor) ; sort the data qsort(nor2) iarr=new((/2,5/),float) ; fill with minimum, 25th percentile, median, 75th percentile, maximum of each timeseries iarr(0,:) = (/min(nor),nor(x25),dim_median(nor),nor(x75),max(nor)/) iarr(1,:) = (/min(nor2),nor2(x25),dim_median(nor2),nor2(x75),max(nor2)/) wks = gsn_open_wks("x11","box") ; create postscript file lineRes = True lineRes@gsnDraw = False lineRes@gsnFrame = False lineRes@trYMinF = 230. lineRes@trYMaxF = 345. lineGraph = gsn_csm_y( wks, (/ nor, nor2 /), lineRes ) draw(lineGraph) frame(wks) boxRes = True ; plot mods desired boxRes@tmXBLabels = (/"Control","Run A"/) ; labels for each box boxRes@tiMainString = "Box Plot" boxRes@trYMinF = 230. boxRes@trYMaxF = 345. boxGraph = boxplot(wks,(/0,1/),iarr,False,boxRes,False) draw(boxGraph) frame(wks) attach = gsn_attach_plots( lineGraph, boxGraph, False, False ) draw(wks) ; boxplot does not call these frame(wks) ; for you end