Advertisement
Guest User

Untitled

a guest
Jun 13th, 2012
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.60 KB | None | 0 0
  1.  
  2. load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"  ; Load the NCL file that
  3.                      ; contains the gsn_* functions used below.
  4. begin
  5.   x = new(9,float)  ; Define two 1D arrays of 9 elements each.
  6.   y = new(9,float)
  7.  
  8.   x = (/10.,20.,30.,40.,50.,60.,70.,80.,90./)
  9.   y = (/0.,0.71,1.,0.7,0.002,-0.71,-1.,-0.71,-0.003/)
  10.  
  11. ; wks = gsn_open_wks("x11","gsun01n")  ; Open an X11 workstation.
  12. wks = create "ps" psWorkstationClass noparent
  13.      "wkVisualType" : "color"
  14.      "wkPSFileName" : "output.ps"
  15.      "wkOrientation" : "portrait"
  16. end create
  17.  
  18.   plot = gsn_xy(wks,x,y,False)         ; Draw an XY plot with 1 curve.
  19.  
  20. ;----------- Begin second plot -----------------------------------------
  21.  
  22.    y2 = (/(/0., 0.7, 1., 0.7, 0., -0.7, -1., -0.7, 0./),\
  23.          (/2., 2.7, 3., 2.7, 2.,  1.3,  1.,  1.3, 2./),\
  24.          (/4., 4.7, 5., 4.7, 4.,  3.3,  3.,  3.3, 4./)/)
  25.  
  26.   x@long_name  = "X"             ; Define attributes of x
  27.   y2@long_name = "Y"             ; and y2.
  28.  
  29.   plot = gsn_xy(wks,x,y2,False)  ; Draw an XY plot with 3 curves.
  30.  
  31. ;---------- Begin third plot -----------------------------------------
  32.  
  33.   resources                    = True          ; Indicate you want to
  34.                                                ; set some resources.
  35.  
  36.   resources@xyLineColors        = (/2,3,4/)    ; Define line colors.
  37.   resources@xyLineThicknesses   = (/1.,2.,5./) ; Define line thicknesses
  38.                                                ; (1.0 is the default).
  39.  
  40.   plot = gsn_xy(wks,x,y2,resources)            ; Draw an XY plot.
  41.  
  42. ;---------- Begin fourth plot ------------------------------------------
  43.  
  44.   resources@tiMainString    = "X-Y plot"  ; Title for the XY plot
  45.   resources@tiXAxisString   = "X Axis"    ; Label for the X axis
  46.   resources@tiYAxisString   = "Y Axis"    ; Label for the Y axis
  47.   resources@tiMainFont      = "Helvetica" ; Font for title
  48.   resources@tiXAxisFont     = "Helvetica" ; Font for X axis label
  49.   resources@tiYAxisFont     = "Helvetica" ; Font for Y axis label
  50.  
  51.   resources@xyMarkLineModes = (/"Lines","Markers","MarkLines"/)
  52.   resources@xyMarkers       = (/0,1,3/)   ; (none, dot, asterisk)
  53.   resources@xyMarkerColor   = 3           ; Marker color
  54.   resources@xyMarkerSizeF   = 0.03        ; Marker size (default
  55.                                           ; is 0.01)
  56.  
  57.   plot = gsn_xy(wks,x,y2,resources)       ; Draw an XY plot.
  58.  
  59. ;---------- Begin fifth plot ------------------------------------------
  60.  
  61.   filename = "$NCARG_ROOT/lib/ncarg/data/asc/xy.asc"
  62.  
  63.   data = asciiread(filename,(/129,4/),"float")
  64.  
  65.   uv      = new((/2,129/),float)
  66.   uv(0,:) = data(:,1)
  67.   uv(1,:) = data(:,2)
  68.  
  69.   lon     = data(:,0)
  70.   lon     = (lon-1) * 360./128.
  71.  
  72.   delete(resources) ; Start with new list of resources.
  73.  
  74.   resources                        = True
  75.  
  76.   resources@tiMainString           = "U/V components of wind"
  77.   resources@tiXAxisString          = "longitude"
  78.   resources@tiYAxisString          = "m/s"
  79.   resources@tiXAxisFontHeightF     = 0.02        ; Change the font size.
  80.   resources@tiYAxisFontHeightF     = 0.02
  81.  
  82.   resources@xyLineColors           = (/3,4/)     ; Set the line colors.
  83.   resources@xyLineThicknessF       = 2.0         ; Double the width.
  84.  
  85.   resources@xyLabelMode            = "Custom"    ; Label XY curves.
  86.   resources@xyExplicitLabels       = (/"U","V"/) ; Labels for curves
  87.   resources@xyLineLabelFontHeightF = 0.02        ; Font size and color
  88.   resources@xyLineLabelFontColor   = 2           ; for line labels
  89.  
  90.   plot = gsn_xy(wks,lon,uv,resources) ; Draw an XY plot with 2 curves.
  91.  
  92.   delete(plot)       ; Clean up.
  93.   delete(resources)
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement