Re: Few Questions

From: Mary Haley (haley AT XXXXXX)
Date: Thu Mar 29 2001 - 16:38:21 MST

  • Next message: Julie Arblaster: "named subscripting"

    Maurice writes:

    > .
    > .
    > .
    > I modified one of Dennis Shea's spectral analysis example scripts
    > (called spec_3.ncl) and would like to add spectral periodicities
    > running horizontally above the top x-axis in the diagram in addition
    > to the spectral frequecies running below the bottom x-axis currently
    > used in the script.
    > .
    > .
    > .

    I'm going to answer this question separately from the other ones that
    Maurice included in his original message, since it's a common request
    that we get from our users.

    In order to label the top X axis, you need to turn on the top axis
    resources, since they are turned off by default. Also, since you want
    to label the top axis with values different than what the bottom axis
    is set with, you need to set "tmXUseBottom" to False to indicate to
    ncl that you don't want to use the same labels on the bottom axis for
    your top axis.

    Here, then, are the resources you'll need to set:

      res@tmXUseBottom = False ; Keep top axis independent of bottom.
      res@tmXTLabelsOn = True ; Turn on drawing of top axis labels.
      res@tmXTOn = True ; Turn on drawing of top axis tick marks.

      res@tmXTMode = "Explicit" ; Define own tick mark labels.
      res@tmXTValues = (/.../) ; Set to values in same data space as
                                     ; bottom axis.
      res@tmXTLabels = (/.../) ; Array of labels that corresponds with
                                     ; values in the tmXTValues array.

    Here's a simplified NCL script that demonstrates how to label the
    top X axis.

    load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"

    begin
    ;
    ; Generate some dummy data.
    ;
      x = (/10.,20.,30.,40.,50.,60.,70.,80.,90./)
      y = (/0.0,0.7,1.0,0.7,0.002,-0.71,-1.0,-0.71,-0.003/)

      wks = gsn_open_wks("x11","example")

      res = True

      res@tmXUseBottom = False ; Keep top axis independent of bottom.
      res@tmXTLabelsOn = True ; Turn on top axis labels.
      res@tmXTOn = True ; Turn on top axis tick marks.

    ;
    ; Set the values where you want tick marks to appear on the top
    ; axis, and then indicate the labels you want at these values.
    ; Note that the values must be in the same data space as the
    ; original X axis.
    ;
      res@tmXTMode = "Explicit"
      res@tmXTValues = (/ 5. , 25. , 45. , 65. , 85./)
      res@tmXTLabels = (/"Jan","Feb","Mar","Apr","Jun"/)

      plot = gsn_xy(wks,x,y,res) ; Draw an XY plo.t
    end

    --Mary



    This archive was generated by hypermail 2b29 : Thu Mar 29 2001 - 16:39:00 MST