Re: errorbars on scatterplots

From: Dennis Shea (shea AT XXXXXX)
Date: Thu Jun 20 2002 - 11:27:12 MDT

  • Next message: Mary Haley: "We need some HDF-EOS files for testing purposes"

    Hello
      
    Is this what you are asking for at each point on the graph?
      
                     
                     |
                     |
                   --*----- (asymmetric x/y error bars)
                     |
                     |
                     |
                      

    Either gsn_add_polyline or gsn_polyline can be used.
    If gsn_panel is to be used then u *must* use gsn_add_polyline.

    One example of using gsn_polyline and other gsn_poly* templates
    is at:

         http://ngwww.ucar.edu/ngdoc/ng/ug/ncl/gsun/examples/gsun07n.html
         
    The above shows how you might add gsn_polyline resources (resPL
    in the example below)
         
    Other gsn_poly* examples are at are at:

         http://www.cgd.ucar.edu/csm/support/CSM_Graphics/polyg.shtml
         http://www.cgd.ucar.edu/csm/support/CSM_Graphics/line.shtml
                see example 5
                
    The following (untested) code snippet below will draw the error bar
    right through the * polymarker which, I suspect, is not
    exactly what you want but it illustrates what you
    need to do:

    This uses gas_add_polyline (it works whether you are going
                                to use gsn_panel or not. It is
                                more 'general' but a bit more
                                involved.)

    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
    begin
        [SNIP]
      X = new ( 2, typeof(x) )
      Y = new ( 2, typeof(y) )
      dumX = new ( npts, graphic ) ; unique to hold each error bar
      dumY = new ( npts, graphic )

      res = True
      res@gsnDraw = False
      res@gsnFrame = False
                   : other resources set
                  
      resPL = True/False ; depending on whether u want resources
                             ; set for the error bar lines
                  
      plot = gsn_csm_xy (wks,x,y,res)
      
      do n=0,npts-1 ; loop thru pts to draw error bars
                                        ; left to right error bar
        X(0) = x(n) - extent_to_left_of_point
        X(1) = x(n) + extent_to_right_of_point
        Y(0) = y(n)
        Y(1) = y(n)

        dumX(n) = gsn_add_polyline (wks,plot,X,Y,resPL)
                                        ; bottom to top
        X(0) = x(n)
        X(1) = x(n)
        Y(0) = y(n) - extent_below_point
        Y(1) = y(n) + extent_above_point
        dumY(n) = gsn_add_polyline (wks,plot,X,Y,resPL)
            
      end do
      draw(plot)
      frame(wks)

      [SNIP]
    end
    --------------------------------------------------
    The following assumes u are not going to use gsn_panel. It
    uses gsn_polyline. It is a bit simpler:

    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
    begin
        [SNIP]
      X = new ( 2, typeof(x) )
      Y = new ( 2, typeof(y) )
      
      res = True
      res@gsnDraw = False
      res@gsnFrame = False
                   : other resources set
                  
      resPL = True/False ; depending on whether u want resources
                             ; set for the error bar lines
                  
      plot = gsn_csm_xy (wks,x,y,res)
      
      do n=0,npts-1 ; loop thru pts to draw error bars
                                        ; left to right error bar
        X(0) = x(n) - extent_to_left_of_point
        X(1) = x(n) + extent_to_right_of_point
        Y(0) = y(n)
        Y(1) = y(n)

        gsn_polyline (wks,plot,X,Y,resPL)
                                        ; bottom to top
        X(0) = x(n)
        X(1) = x(n)
        Y(0) = y(n) - extent_below_point
        Y(1) = y(n) + extent_above_point
        gsn_polyline (wks,plot,X,Y,resPL)
            
      end do
      draw(plot)
      frame(wks)

    good luck
    Dennis Shea

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Thu Jun 20 2002 - 15:44:46 MDT