; ; This procedure draws a unit NDC grid at every 0.1 spaces, and labels ; each line. ; procedure draw_unit_square(wks,res) begin ; ; Don't bother to draw grid if gsnMaximize is equal to True. ; if(isatt(res,"gsnMaximize").and.res@gsnMaximize) then return end if ; ; Spacing values for NDC grid. ; xndc = fspan(0,1,11) ; (/0,.1,.2,...,1.) yndc = xndc ; ; Set up some resource lists. ; lnres = True txres = True ; ; Set up resources for NDC grid and labels. ; lnres@gsLineColor = "LightGray" ; Gray lines lnres@gsLineThicknessF = 2 ; 2x as thick txres@txFontHeightF = .015 ; Slightly smaller than default txres@txFontColor = "red" ; Red text ; ; Draw NDC grid with labels. ; txres@txJust = "TopCenter" do i=0,dimsizes(xndc)-1 gsn_polyline_ndc(wks,(/xndc(i),xndc(i)/),(/0,1/),lnres) ; ; Don't draw labels at ends of grid. ; if(i.ne.0.and.i.ne.dimsizes(xndc)-1) then gsn_text_ndc(wks,"x="+xndc(i),xndc(i),.98,txres) end if end do txres@txJust = "CenterLeft" do i=0,dimsizes(yndc)-1 gsn_polyline_ndc(wks,(/0,1/),(/yndc(i),yndc(i)/),lnres) if(i.ne.0.and.i.ne.dimsizes(yndc)-1) then gsn_text_ndc(wks,"y="+yndc(i),.02,yndc(i),txres) end if end do end ; ; This procedure draws lines, text, and markers showing the vpXF, ; vpYF location, and the width and height of the plot. ; procedure draw_viewport_labels(wks,plot,res) begin ; ; Don't bother to draw labels if gsnMaximize is equal to True. ; if(isatt(res,"gsnMaximize").and.res@gsnMaximize) then return end if ; ; Retrieve view port values. ; getvalues plot "vpHeightF" : vph "vpWidthF" : vpw "vpXF" : vpx "vpYF" : vpy end getvalues ; ; Set up some resource lists. ; lnres = True txres = True mkres = True ; ; Draw marker at position (vpXF,vpYF). ; mkres@gsMarkerIndex = 16 ; Filled dot mkres@gsMarkerColor = "blue" ; Blue dot mkres@gsMarkerSizeF = 20 ; Bigger dot gsn_polymarker_ndc(wks,vpx,vpy,mkres) ; ; Draw text strings indicating vpXF and vpYF values. ; txres@txFontHeightF = .02 txres@txFontColor = "blue" gsn_text_ndc(wks,"("+vpx+","+vpy+")",vpx,vpy+.07,txres) gsn_text_ndc(wks,"(vpXF,vpYF)",vpx,vpy+.03,txres) ; ; Draw lines and text showing vpWidthF and vpHeightF values. ; lnres@gsLineColor = "Blue" lnres@gsLineThicknessF = 2 txres@txBackgroundFillColor = "white" gsn_polyline_ndc(wks,(/vpx,vpx+vpw/),(/vpy-.25*vph,vpy-.25*vph/),lnres) gsn_text_ndc (wks,"vpWidthF="+vpw,vpx+vpw/2.,vpy-.25*vph,txres) txres@txAngleF = 90 ; Rotate 90 degrees gsn_polyline_ndc(wks,(/vpx+.25*vpw,vpx+.25*vpw/),(/vpy,vpy-vph/),lnres) gsn_text_ndc (wks,"vpHeightF="+vph,vpx+.25*vpw,vpy-vph/2,txres) end