; ; This example shows how to create a polar stereographic plot with ; the lat/lon grid labeled. ; begin ; ; Create an X workstation to draw on. ; wid = create "map" xWorkstationClass defaultapp end create ; ; Create a polar stereographic map. ; mpid = create "mapplot" mapPlotClass wid "vpXF" : 0.10 ; Change the location and "vpYF" : 0.90 ; the width and height "vpWidthF" : 0.78 ; of the map. "vpHeightF" : 0.78 "mpProjection" : "Stereographic" "mpCenterLatF" : 90.0 ; Change the center of "mpCenterLonF" : -90.0 ; the projection. "mpEllipticalBoundary" : True ; Here's what makes it elliptical. "mpLimitMode" : "LatLon" ; Change the map limit mode "mpMinLatF" : 0.0 ; so that only the northern "mpMaxLatF" : 90.0 ; hemisphere is visible. "mpMinLonF" : -180.0 "mpMaxLonF" : 180.0 end create ; ; Draw the map. ; draw(mpid) ; ; Change the viewport of the map object we just created to generate a ; new data space for lat/lon text. Make the new viewport slightly larger ; than the one the map was drawn in, because we want to draw the ; labels on the outside of the map. ; setvalues mpid "vpXF" : 0.07 "vpYF" : 0.93 "vpWidthF" : 0.84 "vpHeightF" : 0.84 end setvalues ; ; Create a generic TextItem object that we'll use to label the lat/lon ; grid. ; txid = create "text" textItemClass wid "txFont" : 22 ; Change the font to 22 (helvetica). "txFontHeightF" : 0.015 ; Change the size of the font. end create ; ; Define an array of strings to label the longitude values. ; labels = (/"0","30E","60E","90E","120E","150E","180","150W",\ "120W","90W","60W","30W"/) ; ; Create the lat/lon coordinates where you want labels to appear. ; In this case, we want the labels to appear at the equator (lat=0), ; and at longitude values of 0, 30, 60, ..., 330. ; lat = fspan(0.,0.,12) lon = fspan(0.,330.,12) ; ; Create arrays to hold the NDC values that we're going to convert ; the lat/lon values to. ; xndc = new(dimsizes(lon),float) yndc = new(dimsizes(lat),float) ; ; Convert lat/lon coordinates to NDC coordinates since we are ; drawing the labels in NDC space and NOT in lat/lon space. ; datatondc(mpid,lon,lat,xndc,yndc) ; ; Draw each string. ; do i=0,dimsizes(labels)-1 setvalues txid "txString" : labels(i) "txPosXF" : xndc(i) "txPosYF" : yndc(i) end setvalues draw(txid) end do ; ; Advance the frame. ; frame(wid) end