Http://www.ncl.ucar.edu/Document/Manuals/Getting_Started/Examples/gsun01n.shtmlOutput from Example 1
Frame 1 |
Frame 2 |
Frame 3 |
Frame 4 |
Frame 5 |
|
|
|
|
|
(Click on any frame to see it enlarged .)
NCL code for example 1
1.Load "$ ncarg_root/lib/ncarg/nclscripts/CSM/gsn_code.ncl"; load the NCL file containing the GSN _ Function3.Begin; the program starts4.X = new (9, float); defines a one-dimensional array containing nine elements (C = new (/5, 6, 7/), integer) A = (/true, false, true /))5.Y = new (9, float)6. 7.X = (/10., 20., 30., 40., 50., 60., 70., 80., 90 ./)8.Y = (/0., 0.71, 1., 0.7, 0.002,-0.71,-1.,-0.71,-0.003 /)9. 10.Wks = gsn_open_wks ("X11", "gsun01n"); open an X11 Workstation11. 12.Plot = gsn_xy (wks, X, Y, false); plot an XY curve.13. 14.; ----------- Begin second plot -----------------------------------------15. 16.Y2 = (/0., 0.7, 1., 0.7, 0.,-0.7,-1.,-0.7, 0 ./),17.(/2., 2.7, 3., 2.7, 2., 1.3, 1., 1.3, 2 ./),18.(/4., 4.7, 5., 4.7, 4., 3.3, 3., 3.3, 4./); this is a one-dimensional array of 27 elements.19. 20.[Email protected] _ name = "X"; defines an attribute of X.21.[Email protected] _ name = "Y"; defines an attribute of Y2.22. 23.Plot = gsn_xy (wks, X, Y2, false); draw a XY plot containing three curves24. 25.; ----------- Begin third plot -----------------------------------------26. 27.Resources = true; indicates that resources need to be set29. 30.[Email protected]Xylinecolors= (/2, 3, 4/); set the line color31.[Email protected]Xylinethicknesses= (/1., 2., 5./); set the line width.32.; (The default value is 1.0 ).33. 34.Plot = gsn_xy (wks, X, Y2, resources); draw a XY plot.35. 36.; ---------- Begin fourth plot ------------------------------------------37. 38.[Email protected]Timainstring= "X-Y plot"; Title39.[Email protected]Tixaxisstring= "X axis"; X axis label40.[Email protected]Tiyaxisstring= "Y axis"; Y axis label41.[Email protected]Timainfont= "Helvetica"; title Font42.[Email protected]Tixaxisfont= "Helvetica"; X axis label font43.[Email protected]Tiyaxisfont= "Helvetica"; Y axis label font44. 45.[Email protected]Xymarklinemodes= (/"Lines", "Markers", "marklines "/)46.[Email protected]Xymarkers= (/0, 1, 3/); (none, Dot, asterisk)47.[Email protected]Xymarkercolor= 3; Mark color48.[Email protected]Xymarkersizef= 0.03; tag size49.; The default value is 0.01.50. 51.Plot = gsn_xy (wks, X, Y2, resources); draw a XY plot.52. 53.; ---------- Begin fifth plot ------------------------------------------54. 55.Filename = "$ ncarg_root/lib/ncarg/data/ASC/XY. ASC"56. 57.Data = asciiread (filename, (/129,4/), "float"); input data to read parameter files with floating point, data array specifications :(/129,4 /)58. 59.UV = new (/2,129/), float)60.UV (0, :) = data (:, 1)61.UV (1, :) = data (:, 2)62. 63.Lon = data (:, 0)64.Lon = (lon-1) * 360./128.65. 66.Delete (resources); Delete the previously set Resources67. 68.Resources = true69. 70.[Email protected]Timainstring= "U/V components of Wind"71.[Email protected]Tixaxisstring= "Longpolling"72.[Email protected]Tiyaxisstring= "M/s"73.[Email protected]Tixaxisfontheightf= 0.02; change the font size74.[Email protected]Tiyaxisfontheightf= 0.0275. 76.[Email protected]Xylinecolors= (/3, 4/); set the line color77.[Email protected]Xylinethicknessf= 2.0; line width is set to twice the original78. 79.[Email protected]Xylabelmode= "Custom"; set the curve label80.[Email protected]Xyexplicitlabels= (/"U", "V"/); curve label81.[Email protected]Xylinelabelfontheightf= 0.02; size and color82.[Email protected]Xylinelabelfontcolor= 2; line label83. 84.Plot = gsn_xy (wks, Lon, UV, resources); Draw XY plot of Two Curves85. 86.Delete (PLOT); clear the drawing panel87.Delete (resources); Delete Resources88.End
Example 1-XY plots