Re: plot lines using their own starting and ending times with different time lengths

From: Dennis Shea (shea AT XXXXXX)
Date: Tue Jan 22 2002 - 12:04:24 MST

  • Next message: Larry Horowitz: "ECMWF grib files"

    >
    >I want to plot this figure. I have
    >four or more time data with different time lengths, different starting time and
    >ending time. I want to plot them in the same figure, sharing the same x and y,
    >with each of them starts and ends at the their own times series. How can I
    >succeed this?
    >

    Let's say you have 4 x-y series: x1,y1
                                     x2,y2
                                     x3,y3
                                     x4,y4
                                     
    There are two approaches but this is the one I use (sketch):

    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

    Create 2D arrays that hold the data

    ; determine the max number of elements required

        nxy1 = dimsizes(x1)
        nxy2 = dimsizes(x2)
        nxy3 = dimsizes(x3)
        nxy4 = dimsizes(x4)

        nxy = max ( (/nxy1, nxy2, nxy3, nxy4/) )
        
    ; allocate space

        X = new( (/4,nxy/), typeof(x1) )
        Y = new( (/4,nxy/), typeof(y1) )
        
        X(0,0:nxy1-1) = x1
        Y(0,0:nxy1-1) = y1
        X(1,0:nxy2-1) = x2
        Y(1,0:nxy2-1) = y2
        X(2,0:nxy3-1) = x3
        Y(2,0:nxy3-1) = y3
        X(3,0:nxy4-1) = x4
        Y(3,0:nxy4-1) = y4
        
        X@long_name = "whatever" ; or x1@long_name
        X@units = "whatever" ; or x1@units
        
        Y@long_name = "whatever" ; or y1@long_name
        Y@units = "whatever" ; or y1@units
        
        
    use either

        res = True
              :
        plot = gsn_xy (wks,X,Y,res)
        
    or plot = gsn_csm_xy (wks,X,Y,res)

    The 2nd undescribed approach is to use "gsn_polyline" or
    "gsn_add_polyline" These are described at:
           http://ngwww.ucar.edu/ngdoc/ng/ug/ncl/gsun/appendixa.html
           
    examples can be clicked upon:

    also see: http://www.cgd.ucar.edu/csm/support/CSM_Graphics/line.shtml

    for some examples



    This archive was generated by hypermail 2b29 : Tue Jan 22 2002 - 13:32:06 MST