all/taylor_diagram.ncl
changeset 0 0c6405ab2ff4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/all/taylor_diagram.ncl	Mon Jan 26 22:08:20 2009 -0500
     1.3 @@ -0,0 +1,479 @@
     1.4 +function taylor_diagram (wks:graphic ,RATIO[*][*]:numeric, CC[*][*]:numeric \
     1.5 +                                     ,rOpts:logical)
     1.6 +;--------------------------------------------------------------------
     1.7 +; This version of taylor_diagram supports "paneling"
     1.8 +; It requires NCL version 4.2.0.a034 because it uses "gsn_create_legend"
     1.9 +;--------------------------------------------------------------------
    1.10 +
    1.11 +;
    1.12 +; Generate a Taylor Diagram:
    1.13 +; Generate Multiple Aspects of Model Performance in a Single Diagram
    1.14 +; Taylor, K. E., J. Geophys. Res., 106, D7, 7183-7192, 2001
    1.15 +;
    1.16 +; An example:
    1.17 +; http://www.grida.no/climate/ipcc_tar/wg1/fig8-4.htm
    1.18 +;
    1.19 +; This expects one or more datasets. The left dimension 
    1.20 +; is the number of datasets. The rightmost is the number of pts.
    1.21 +;
    1.22 +; Markers are at: 
    1.23 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
    1.24 +;
    1.25 +; By default, the function can handle up to 10 variable comparisons..
    1.26 +; To expand ...  modify the 'Colors' and 'Markers' attributes.
    1.27 +; The user can change / add some default settings.
    1.28 +;
    1.29 +; The defaults that the user can modify:
    1.30 +;
    1.31 +; rOpts                 = True 
    1.32 +;                                  ; 'made-up' resources
    1.33 +; rOpts@Colors          =  (/ "blue" , "red", "green", "cyan", "black" \
    1.34 +;                           , "torquoise", "brown", "yellow"/)
    1.35 +; rOpts@Markers         =  (/ 2, 3, 6, 14, 9, 12, 7, 4/) ; Marker Indices
    1.36 +; rOpts@markerTxOffset  = 0.0175   ; offset for text above marker
    1.37 +; rOpts@stnRad          = (/ 1. /) ;  (/ 0.50, 0.75, 1.5 /) 
    1.38 +; rOpts@centerDiffRMS   = False    ;  True mean draw additional radii from REF 
    1.39 +; rOpts@caseLabelsFontHeightF = 0.05
    1.40 +; rOpts@varLabelsFontHeightF  = 0.013
    1.41 +; rOpts@varLabelsYloc         = 0.65
    1.42 +; rOpts@legendWidth           = 0.015
    1.43 +; rOpts@legendHeight          = 0.030*nCase
    1.44 +; rOpts@taylorDraw            = True
    1.45 +; rOpts@taylorFrame           = True
    1.46 +;
    1.47 +;                                  ; standard NCL resources
    1.48 +; rOpts@tiMainString    = "Taylor" ; not using title makes plot bigger
    1.49 +; rOpts@gsMarkerSizeF   = 0.0085   ; marker size   
    1.50 +; rOpts@gsMarkerThicknessF = 1.0
    1.51 +; rOpts@txFontHeightF   = 0.0125   ; text size 
    1.52 +; rOpts@tiMainFontHeightF = 0.0225 ; tiMainString size
    1.53 +;
    1.54 +; It returns to the user a graphic object containing the 
    1.55 +; Taylor background and plotted x/y pts.
    1.56 +; This graphic object contains a simple Taylor background appropriate
    1.57 +; for standardized data and the markers for the datasets.
    1.58 +; ==================================================================
    1.59 +; This version allows paneling:
    1.60 +;      The 'cumbersome' "dum" variables were added by 
    1.61 +;      Adam Phillips to allow paneling via "gsn_add_?".
    1.62 +; ==================================================================
    1.63 +begin
    1.64 +  dimR                  = dimsizes(RATIO)
    1.65 +  nCase                 = dimR(0)    ; # of cases [models] 
    1.66 +  nVar                  = dimR(1)    ; # of variables
    1.67 +
    1.68 +                                     ; x/y coordinates for plotting
    1.69 +  X    = new ( (/nCase,nVar/) , typeof(RATIO) )
    1.70 +  Y    = new ( (/nCase,nVar/) , typeof(RATIO) )
    1.71 +
    1.72 +  do nc=0,nCase-1
    1.73 +     angle      = acos( CC(nc,:) )   ; array operation                                    
    1.74 +     X(nc,:)    = RATIO(nc,:)*cos( angle )     
    1.75 +     Y(nc,:)    = RATIO(nc,:)*sin( angle )    
    1.76 +  end do
    1.77 +
    1.78 +  xyMin                 = 0.  
    1.79 +  xyOne                 = 1.00
    1.80 +  xyMax                 = 1.65
    1.81 +  xyMax_Panel           = xyMax+ 0.10            ; paneling purposes
    1.82 + 
    1.83 +  if (rOpts .and. isatt(rOpts,"txFontHeightF"))  then 
    1.84 +      FontHeightF       = rOpts@txFontHeightF    ; user wants to specify size
    1.85 +  else
    1.86 +      FontHeightF       = 0.0175
    1.87 +  end if
    1.88 + 
    1.89 +; ----------------------------------------------------------------
    1.90 +; Part 1:
    1.91 +; base plot: Based upon request of Mark Stevens
    1.92 +; basic x-y and draw the 1.0 observed and the outer curve at 1.65
    1.93 +; ----------------------------------------------------------------
    1.94 +  
    1.95 +  rxy                   = True       
    1.96 +  rxy@gsnDraw           = False
    1.97 +  rxy@gsnFrame          = False
    1.98 +  rxy@vpHeightF         = 0.65
    1.99 +  rxy@vpWidthF          = 0.65
   1.100 +  rxy@tmYLBorderOn      = False
   1.101 +  rxy@tmXBBorderOn      = False
   1.102 +
   1.103 +  rxy@tiYAxisString     = "Standardized Deviation (Normalized)"
   1.104 +  rxy@tiYAxisFontHeightF= FontHeightF                        ; default=0.025 
   1.105 +  
   1.106 +  rxy@tmXBMode          = "Explicit" 
   1.107 +  rxy@tmXBValues        = (/0.0,0.25,0.50,0.75,1.00,1.25,1.5/)    ; major tm
   1.108 +                                                                  ; default  "OBS" or "REF"
   1.109 + ;rxy@tmXBLabels        = (/"0.00","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
   1.110 +  rxy@tmXBLabels        = (/"    ","0.25","0.50","0.75","REF" ,"1.25","1.50"/)
   1.111 +  if (rOpts .and. isatt(rOpts,"OneX") )  then                     ; eg: rOpts@OneX="1.00" 
   1.112 +     ;rxy@tmXBLabels        = (/"0.00","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
   1.113 +      rxy@tmXBLabels        = (/"    ","0.25","0.50","0.75",rOpts@OneX,"1.25","1.50"/)
   1.114 +  end if
   1.115 +
   1.116 +  rxy@tmXBMajorLengthF  = 0.015      ; default=0.02 for a vpHeightF=0.6
   1.117 +  rxy@tmXBLabelFontHeightF = FontHeightF
   1.118 +  rxy@tmXBMinorOn       = False
   1.119 +  rxy@trXMaxF           = xyMax_Panel
   1.120 +
   1.121 +  rxy@tmYLMode          = "Manual"
   1.122 +  rxy@tmYLMinorOn       = False
   1.123 +  rxy@tmYLMajorLengthF  = rxy@tmXBMajorLengthF
   1.124 +  rxy@tmYLLabelFontHeightF = FontHeightF
   1.125 +  rxy@tmYLMode          = "Explicit" 
   1.126 +  rxy@tmYLValues        = (/0.0, .25,0.50, 0.75, 1.00, 1.25, 1.5/) ; major tm
   1.127 +  rxy@tmYLLabels        = (/"0.00","0.25","0.50","0.75","1.00","1.25","1.50"/)
   1.128 + ;rxy@tmYLLabels        = (/"    ","0.25","0.50","0.75","1.00","1.25","1.50"/)
   1.129 +  rxy@trYMaxF           = xyMax_Panel
   1.130 +
   1.131 +  rxy@tmYRBorderOn      = False
   1.132 +  rxy@tmYROn            = False      ; Turn off right tick marks.
   1.133 +
   1.134 +  rxy@tmXTBorderOn      = False
   1.135 +  rxy@tmXTOn            = False      ; Turn off right tick marks.
   1.136 +
   1.137 +  rxy@xyDashPatterns    = (/ 0 /)    ; line characteristics (dash,solid)
   1.138 +  rxy@xyLineThicknesses = (/ 2./)    ; choose line thickness
   1.139 +
   1.140 +  rxy@gsnFrame          = False      ; Don't advance the frame.
   1.141 +
   1.142 +                                            ; create outer 'correlation axis'
   1.143 +  npts    = 200                        ; arbitrary
   1.144 +  xx      = fspan(xyMin,xyMax,npts) 
   1.145 +  yy      = sqrt(xyMax^2 - xx^2    )   ; outer correlation line (xyMax)
   1.146 +
   1.147 +  sLabels = (/"0.0","0.1","0.2","0.3","0.4","0.5","0.6" \ ; correlation labels
   1.148 +             ,"0.7","0.8","0.9","0.95","0.99","1.0"     /); also, major tm
   1.149 +  cLabels = stringtofloat(sLabels)
   1.150 +  rad     = 4.*atan(1.0)/180.
   1.151 +  angC    = acos(cLabels)/rad                     ; angles: correlation labels
   1.152 +                                                                       
   1.153 +  if (rOpts .and. isatt(rOpts,"tiMainString")) then
   1.154 +      rxy@tiMainString      = rOpts@tiMainString
   1.155 +     ;rxy@tiMainOffsetYF    = 0.015               ; default  0.0
   1.156 +      if (isatt(rOpts,"tiMainFontHeightF")) then
   1.157 +           rxy@tiMainFontHeightF = rOpts@tiMainFontHeightF
   1.158 +      else
   1.159 +           rxy@tiMainFontHeightF = 0.0225         ; default  0.025              
   1.160 +      end if
   1.161 +  end if
   1.162 +;;if (rOpts .and. isatt(rOpts,"gsnCenterString")) then
   1.163 +;;    rxy@gsnCenterString  = rOpts@gsnCenterString      ; only gsn_csm_xy
   1.164 +;;end if
   1.165 +
   1.166 +  taylor  = gsn_xy(wks,xx,yy,rxy)                 ; Create and draw XY plot.
   1.167 +
   1.168 +  rsrRes  = True
   1.169 +  rsrRes@gsLineThicknessF  = rxy@xyLineThicknesses(0)  ; line thickness
   1.170 +  rsrRes@gsLineDashPattern = 0                    ; solid line pattern
   1.171 +                                                  ; draw x and y to xyMax
   1.172 +  dum0 = gsn_add_polyline(wks,taylor,(/0.,  0. /),(/0.,xyMax/), rsrRes)
   1.173 +  dum1 = gsn_add_polyline(wks,taylor,(/0.,xyMax/),(/0.,  0. /), rsrRes)
   1.174 +
   1.175 +  xx   = fspan(xyMin, xyOne ,npts)                ; draw 1.0 standard radius
   1.176 +  yy   = sqrt(xyOne - xx^2)   
   1.177 +  rsrRes@gsLineDashPattern = 1                    ; dashed line pattern
   1.178 +  rsrRes@gsLineThicknessF  = rxy@xyLineThicknesses(0)  ; line thickness
   1.179 +  dum2 = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
   1.180 +  delete(xx)
   1.181 +  delete(yy)
   1.182 +                                                  
   1.183 +  if (rOpts .and. isatt(rOpts,"stnRad") ) then
   1.184 +      rsrRes@gsLineThicknessF  = 1   ; rxy@xyLineThicknesses(0)  
   1.185 +      nStnRad = dimsizes(rOpts@stnRad)
   1.186 +
   1.187 +      dum3  = new(nStnRad,graphic)
   1.188 +      do n=0,nStnRad-1
   1.189 +         rr = rOpts@stnRad(n)
   1.190 +         xx = fspan(xyMin, rr ,npts) 
   1.191 +         yy = sqrt(rr^2   - xx^2)   
   1.192 +         dum3(n) = gsn_add_polyline(wks,taylor,xx,yy, rsrRes)
   1.193 +      end do
   1.194 +      taylor@$unique_string("dum")$ = dum3
   1.195 +
   1.196 +      delete(xx)
   1.197 +      delete(yy)
   1.198 +  end if
   1.199 +
   1.200 +  getvalues taylor                                ; get style info from taylor
   1.201 +    "tmYLLabelFont"        : tmYLLabelFont        ; use for correlation axis
   1.202 +    "tmYLLabelFontHeightF" : tmYLLabelFontHeightF
   1.203 +  end getvalues
   1.204 +
   1.205 +; ----------------------------------------------------------------
   1.206 +; Part 2:
   1.207 +; Correlation labels
   1.208 +; ----------------------------------------------------------------
   1.209 +  radC    = xyMax                                  ; for correlation labels
   1.210 +  xC      = radC*cos(angC*rad)
   1.211 +  yC      = radC*sin(angC*rad)
   1.212 +; added to get some separation
   1.213 +  xC      = xC + 0.020*cos(rad*angC)
   1.214 +  yC      = yC + 0.060*sin(rad*angC)
   1.215 +
   1.216 +  txRes               = True                      ; text mods desired
   1.217 +  txRes@txFontHeightF = FontHeightF               ; match YL 
   1.218 +  txRes@tmYLLabelFont = tmYLLabelFont             ; match YL
   1.219 +  txRes@txAngleF      = -45.
   1.220 +  if (.not.isatt(rOpts,"drawCorLabel") .or. rOpts@drawCorLabel) then 
   1.221 +      dum4 = gsn_add_text(wks,taylor,"Correlation",1.30,1.30,txRes)
   1.222 +	 taylor@$unique_string("dum")$ = dum4
   1.223 +  end if
   1.224 +  txRes@txAngleF      = 0.0 
   1.225 +  txRes@txFontHeightF = FontHeightF*0.50          ; bit smaller
   1.226 +
   1.227 +;;dum0 = gsn_add_text(wks,taylor,"OBSERVED",1.00,0.075,txRes)
   1.228 +
   1.229 +  plRes               = True
   1.230 +  plRes@gsLineThicknessF = 2.
   1.231 +  
   1.232 +  txRes@txJust        = "CenterLeft"              ; Default="CenterCenter".
   1.233 +  txRes@txFontHeightF = FontHeightF               ; match YL 
   1.234 + ;txRes@txBackgroundFillColor = "white"
   1.235 +
   1.236 +  tmEnd = 0.975
   1.237 +  radTM = xyMax*tmEnd                             ; radius end: major TM 
   1.238 +  xTM   = new( 2 , "float")
   1.239 +  yTM   = new( 2 , "float")
   1.240 +
   1.241 +  dum5 = new(dimsizes(sLabels),graphic)
   1.242 +  dum6 = dum5
   1.243 +
   1.244 +  do i=0,dimsizes(sLabels)-1                      ; Loop to draw strings
   1.245 +    txRes@txAngleF = angC(i)
   1.246 +    dum5(i) = gsn_add_text(wks, taylor, sLabels(i),xC(i),yC(i),txRes) ; cor label
   1.247 +    xTM(0)   = xyMax*cos(angC(i)*rad)             ; major tickmarks at
   1.248 +    yTM(0)   = xyMax*sin(angC(i)*rad)             ; correlation labels
   1.249 +    xTM(1)   = radTM*cos(angC(i)*rad)             
   1.250 +    yTM(1)   = radTM*sin(angC(i)*rad)
   1.251 +    dum6(i) = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
   1.252 +  end do
   1.253 +                                                  ; minor tm locations
   1.254 +  mTM     = (/0.05,0.15,0.25,0.35,0.45,0.55,0.65 \ 
   1.255 +             ,0.75,0.85,0.91,0.92,0.93,0.94,0.96,0.97,0.98  /)
   1.256 +  angmTM  = acos(mTM)/rad                         ; angles: correlation labels
   1.257 +  radmTM  = xyMax*(1.-(1.-tmEnd)*0.5)             ; radius end: minor TM 
   1.258 +
   1.259 +  dum7 = new(dimsizes(mTM),graphic)
   1.260 +
   1.261 +  do i=0,dimsizes(mTM)-1                          ; manually add tm
   1.262 +    xTM(0)   = xyMax*cos(angmTM(i)*rad)           ; minor tickmarks
   1.263 +    yTM(0)   = xyMax*sin(angmTM(i)*rad)
   1.264 +    xTM(1)   = radmTM*cos(angmTM(i)*rad)          
   1.265 +    yTM(1)   = radmTM*sin(angmTM(i)*rad)
   1.266 +    dum7(i)  = gsn_add_polyline(wks,taylor,xTM,yTM,plRes)
   1.267 +  end do
   1.268 +                                                  ; added for Wanli
   1.269 +  if (rOpts .and. isatt(rOpts,"ccRays") ) then
   1.270 +      angRL = acos(rOpts@ccRays)/rad             ; angles: radial lines
   1.271 +
   1.272 +      rlRes = True
   1.273 +      rlRes@xyDashPattern    = 4  ; line pattern
   1.274 +      rlRes@xyLineThicknessF = 1  ; choose line thickness
   1.275 +
   1.276 +      dum8 = new(dimsizes(angRL),graphic)
   1.277 +      do i=0,dimsizes(angRL)-1
   1.278 +         xRL     = xyMax*cos(angRL(i)*rad)
   1.279 +         yRL     = xyMax*sin(angRL(i)*rad)
   1.280 +         dum8(i) = gsn_add_polyline(wks,taylor,(/0, xRL /),(/0,  yRL  /),rlRes)
   1.281 +      end do
   1.282 +      taylor@$unique_string("dum")$ = dum8
   1.283 +  end if
   1.284 +  
   1.285 +; ----------------------------------------------------------------
   1.286 +; Part 3:
   1.287 +; Concentric about 1.0 on XB axis
   1.288 +; I think this is correct. Still test mode.
   1.289 +; ----------------------------------------------------------------
   1.290 +  if (rOpts .and. isatt(rOpts,"centerDiffRMS") \
   1.291 +            .and. rOpts@centerDiffRMS) then
   1.292 +      respl                    = True                ; polyline mods desired
   1.293 +      respl@gsLineThicknessF   = 1.0                 ; line thickness
   1.294 +      respl@gsLineColor        = "Black"             ; line color     
   1.295 +      respl@gsLineDashPattern  = 2                   ; short dash lines
   1.296 +      
   1.297 +      dx   = 0.25
   1.298 +      ncon = 4                                       ; 0.75, 0.50, 0.25, 0.0
   1.299 +      npts = 100                                     ; arbitrary
   1.300 +      ang  = fspan(180,360,npts)*rad
   1.301 +
   1.302 +      dum9 = new(ncon,graphic)
   1.303 +
   1.304 +      do n=1,ncon 
   1.305 +         rr  = n*dx            ; radius from 1.0 [OBS] abscissa
   1.306 +         xx  = 1. + rr*cos(ang)
   1.307 +         yy  = fabs( rr*sin(ang) )
   1.308 +         if (n.le.2) then
   1.309 +             dum9(n-1) = gsn_add_polyline(wks,taylor,xx,yy,respl)
   1.310 +         end if
   1.311 +         if (n.eq.3) then
   1.312 +             n3 = floattointeger( 0.77*npts ) 
   1.313 +             dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n3),yy(0:n3),respl)
   1.314 +         end if
   1.315 +         if (n.eq.4) then
   1.316 +             n4 = floattointeger( 0.61*npts ) 
   1.317 +             dum9(n-1) = gsn_add_polyline(wks,taylor,xx(0:n4),yy(0:n4),respl)
   1.318 +         end if
   1.319 +      end do
   1.320 +      delete(ang)
   1.321 +      delete(xx)
   1.322 +      delete(yy)
   1.323 +      taylor@$unique_string("dum")$ = dum9
   1.324 +
   1.325 +  end if
   1.326 +; ---------------------------------------------------------------
   1.327 +; Part 4:
   1.328 +; generic resources that will be applied to all users data points
   1.329 +; of course, these can be changed 
   1.330 +; http://www.ncl.ucar.edu/Document/Graphics/Resources/gs.shtml
   1.331 +; ---------------------------------------------------------------
   1.332 +  if (rOpts .and. isatt(rOpts,"Markers")) then
   1.333 +      Markers = rOpts@Markers
   1.334 +  else
   1.335 +      Markers = (/ 4, 6, 8,  0, 9, 12, 7, 2, 11, 16/) ; Marker Indices
   1.336 +  end if
   1.337 +
   1.338 +  if (rOpts .and. isatt(rOpts,"Colors")) then
   1.339 +      Colors  = rOpts@Colors
   1.340 +  else
   1.341 +      Colors  = (/ "red", "blue", "green", "cyan", "orange" \
   1.342 +                 , "torquoise", "brown", "yellow", "purple", "black"/)
   1.343 +  end if
   1.344 +
   1.345 +  if (rOpts .and. isatt(rOpts,"gsMarkerThicknessF")) then
   1.346 +      gsMarkerThicknessF = rOpts@gsMarkerThicknessF
   1.347 +  else
   1.348 +      gsMarkerThicknessF = 1.0
   1.349 +  end if
   1.350 +
   1.351 +  if (rOpts .and. isatt(rOpts,"gsMarkerSizeF")) then
   1.352 +      gsMarkerSizeF      = rOpts@gsMarkerSizeF
   1.353 +  else
   1.354 +      gsMarkerSizeF      = 0.0085                  ; Default: 0.007
   1.355 +  end if
   1.356 +
   1.357 +  gsRes = True
   1.358 +  gsRes@gsMarkerThicknessF = gsMarkerThicknessF      ; default=1.0
   1.359 +  gsRes@gsMarkerSizeF      = gsMarkerSizeF           ; Default: 0.007 
   1.360 +
   1.361 +  ptRes = True                        ; text options for points
   1.362 +  ptRes@txJust             = "BottomCenter"; Default="CenterCenter".
   1.363 +  ptRes@txFontThicknessF   = 1.2      ; default=1.00
   1.364 +  ptRes@txFontHeightF      = 0.0125   ; default=0.05
   1.365 +  if (rOpts .and. isatt(rOpts,"txFontHeightF")) then
   1.366 +      ptRes@txFontHeightF  = rOpts@txFontHeightF  
   1.367 +  end if
   1.368 +
   1.369 +  markerTxYOffset          = 0.0175   ; default
   1.370 +  if (rOpts .and. isatt(rOpts,"markerTxYOffset")) then
   1.371 +      markerTxYOffset = rOpts@markerTxYOffset             ; user defined offset
   1.372 +  end if
   1.373 +
   1.374 +  dum10 = new((nCase*nVar),graphic)
   1.375 +  dum11 = dum10
   1.376 +
   1.377 +  do n=0,nCase-1
   1.378 +     gsRes@gsMarkerIndex   = Markers(n)             ; marker style (+)
   1.379 +     gsRes@gsMarkerColor   = Colors(n)              ; marker color
   1.380 +     ptRes@txFontColor     = gsRes@gsMarkerColor
   1.381 +    do i=0,nVar-1
   1.382 +       dum10(n*nVar+i) = gsn_add_polymarker(wks,taylor,X(n,i),Y(n,i),gsRes) 
   1.383 +;      dum11(n*nVar+i) = gsn_add_text(wks,taylor,(i+1),X(n,i),Y(n,i)+markerTxYOffset,ptRes)
   1.384 +    end do
   1.385 +  end do
   1.386 +
   1.387 +; ---------------------------------------------------------------
   1.388 +; Part 5: ; add case legend and variable labels
   1.389 +; ---------------------------------------------------------------
   1.390 +
   1.391 +  if (rOpts .and. isatt(rOpts,"caseLabels")) then 
   1.392 +
   1.393 +      if (isatt(rOpts,"caseLabelsFontHeightF")) then
   1.394 +          caseLabelsFontHeightF = rOpts@caseLabelsFontHeightF
   1.395 +      else
   1.396 +;         caseLabelsFontHeightF = 0.05
   1.397 +          caseLabelsFontHeightF = 0.15  
   1.398 +      end if
   1.399 +
   1.400 +      lgres                    = True
   1.401 +      lgres@lgMarkerColors     = Colors        ; colors of markers
   1.402 +      lgres@lgMarkerIndexes    = Markers       ; Markers 
   1.403 +      lgres@lgMarkerSizeF      = gsMarkerSizeF ; Marker size
   1.404 +      lgres@lgItemType         = "Markers"     ; draw markers only
   1.405 +      lgres@lgLabelFontHeightF = caseLabelsFontHeightF  ; font height of legend case labels
   1.406 +
   1.407 +      if (isatt(rOpts,"legendWidth")) then
   1.408 +          lgres@vpWidthF       = rOpts@legendWidth
   1.409 +      else
   1.410 +          lgres@vpWidthF       = 0.15           ; width of legend (NDC)
   1.411 +      end if
   1.412 +
   1.413 +      if (isatt(rOpts,"legendHeight")) then
   1.414 +          lgres@vpHeightF      = rOpts@legendHeight
   1.415 +      else   
   1.416 +          lgres@vpHeightF      = 0.030*nCase   ; height of legend (NDC)
   1.417 +      end if
   1.418 +
   1.419 +      lgres@lgPerimOn          = False         ; turn off perimeter
   1.420 +      nModel                   = dimsizes( rOpts@caseLabels )
   1.421 +      lbid = gsn_create_legend(wks,nModel,rOpts@caseLabels,lgres)
   1.422 +	 
   1.423 +      amres = True
   1.424 +      amres@amParallelPosF     =  0.35           
   1.425 +      amres@amOrthogonalPosF   = -0.35             
   1.426 +      annoid1 = gsn_add_annotation(taylor,lbid,amres)	; add legend to plot
   1.427 +  end if
   1.428 +
   1.429 +  if (rOpts .and. isatt(rOpts,"varLabels")) then 
   1.430 +      nVar    = dimsizes(rOpts@varLabels)
   1.431 +
   1.432 +      if (isatt(rOpts,"varLabelsFontHeightF")) then
   1.433 +          varLabelsFontHeightF = rOpts@varLabelsFontHeightF
   1.434 +      else
   1.435 +          varLabelsFontHeightF = 0.013
   1.436 +      end if
   1.437 +
   1.438 +      txres = True
   1.439 +      txres@txFontHeightF = varLabelsFontHeightF
   1.440 +      txres@txJust = "CenterLeft"              ; justify to the center left
   1.441 +
   1.442 +     ;delta_y = 0.02       
   1.443 +      delta_y = 0.06   
   1.444 +      if (rOpts .and. isatt(rOpts,"varLabelsYloc")) then
   1.445 +          ys  = rOpts@varLabelsYloc            ; user specified
   1.446 +      else
   1.447 +          ys  = max( (/nVar*delta_y , 0.30/) )
   1.448 +      end if
   1.449 +
   1.450 +      
   1.451 +      do i = 1,nVar     
   1.452 +         if (i.eq.1) then
   1.453 +             dum12 = new(nVar,graphic)
   1.454 +	 end if
   1.455 +
   1.456 +         dum12(i-1) = gsn_add_text(wks,taylor,i+" - "+rOpts@varLabels(i-1), .125,ys,txres)
   1.457 +         ys = ys- delta_y
   1.458 +      end do
   1.459 +
   1.460 +      taylor@$unique_string("dum")$ = dum12
   1.461 +  end if
   1.462 +
   1.463 +  taylor@$unique_string("dum")$ = dum0   ; x-axis
   1.464 +  taylor@$unique_string("dum")$ = dum1   ; y-axis
   1.465 +  taylor@$unique_string("dum")$ = dum2   ; 1.0 std curve
   1.466 +  taylor@$unique_string("dum")$ = dum5   ; labels [COR]
   1.467 +  taylor@$unique_string("dum")$ = dum6   ; major tm [COR]
   1.468 +  taylor@$unique_string("dum")$ = dum7   ; minor tm
   1.469 +  taylor@$unique_string("dum")$ = dum10  ; markers
   1.470 +  taylor@$unique_string("dum")$ = dum11  ; text
   1.471 +  
   1.472 +  if (.not.isatt(rOpts,"taylorDraw") .or. \
   1.473 +     (isatt(rOpts,"taylorDraw") .and. rOpts@taylorDraw)) then 
   1.474 +	draw(taylor)
   1.475 +  end if
   1.476 +  if (.not.isatt(rOpts,"taylorFrame") .or. \
   1.477 +     (isatt(rOpts,"taylorFrame") .and. rOpts@taylorFrame)) then 
   1.478 +	frame(wks)
   1.479 +  end if
   1.480 +  return(taylor)
   1.481 +end
   1.482 +