Re: xy plot

From: Dave Kennison (kennison AT unknown)
Date: Fri Apr 27 2001 - 08:44:56 MDT

  • Next message: Yosuke Hirata: "ctrans error on CGM element fetching"

    Livio,

    > Hallo , I am making a xy plot and I have this problem:
    > I want to plot 2 variables in 2 separate y axes with the same x axis,
    > without using the ncl routines: I want to use the old NCAR GRAPHICS routine
    > (for istance exy or ezy -AUTOGRAPH).
    > Is it possible? Thank you very much.

    I am enclosing an example that I hope will show you how to do what you want
    using the low-level NCAR Graphics routines of the package AUTOGRAPH. The
    example program is commented and should be relatively easy to follow, I
    hope. Essentially, before drawing the first curve (by calling EZXY), it
    turns off the right and top axes, along with their informational labels,
    and suppresses the frame advance. Then, it turns the frame advance back
    on, turns off the axes that have been drawn, turns on the axes that have
    not been drawn, and calls EZXY to draw the second curve. Stuff related to
    the first curve is in yellow and stuff related to the second curve is in
    cyan; the top label is drawn twice, but ends up in cyan.

    I hope this works for you ...

    Dave Kennison

    Program follows:
    ----------------

          PROGRAM TESTIT
    C
    C Arrays to hold data.
    C
            DIMENSION XCRA(101),YCRA(101)
    C
    C Open GKS.
    C
            CALL OPNGKS
    C
    C Define some colors.
    C
            CALL GSCR (1,0,0.,0.,0.)
            CALL GSCR (1,1,1.,1.,1.)
            CALL GSCR (1,2,1.,1.,0.)
            CALL GSCR (1,3,0.,1.,1.)
    C
    C Move the right and top edges of the grid window inward to provide
    C more room for labels.
    C
            CALL AGSETR ('GRID/RIGHT.',.85)
            CALL AGSETR ('GRID/TOP.',.85)
    C
    C Turn off frame advances by the EZ.... routines.
    C
            CALL AGSETI ('FRAME.',2)
    C
    C Tell AUTOGRAPH to put "nice" values at the ends of the bottom and left
    C axes (which is the default, actually).
    C
            CALL AGSETI ('X/NICE.',-1)
            CALL AGSETI ('Y/NICE.',-1)
    C
    C Tell AUTOGRAPH to put numeric labels on the right axis (when it is
    C turned on).
    C
            CALL AGSETR ('AXIS/RIGHT/NUMERIC/TYPE.',1.E36)
    C
    C Define labels for the left, right, and bottom axes.
    C
            CALL AGSETC ('LABEL/NAME.','L')
            CALL AGSETI ('LINE/NUMBER.',100)
            CALL AGSETC ('LINE/TEXT.','SCALE FOR YELLOW CURVE')
    C
            CALL AGSETC ('LABEL/NAME.','R')
            CALL AGSETI ('LINE/NUMBER.',-100)
            CALL AGSETC ('LINE/TEXT.','SCALE FOR CYAN CURVE')
    C
            CALL AGSETC ('LABEL/NAME.','B')
            CALL AGSETI ('LINE/NUMBER.',-100)
            CALL AGSETC ('LINE/TEXT.','SCALE FOR VALUES OF X')
    C
    C Turn off the right and top axes and turn on the left and bottom axes.
    C
            CALL AGSETI ('AXIS/LEFT/CONTROL.',1)
            CALL AGSETI ('AXIS/RIGHT/CONTROL.',0)
            CALL AGSETI ('AXIS/BOTTOM/CONTROL.',1)
            CALL AGSETI ('AXIS/TOP/CONTROL.',0)
    C
            CALL AGSETC ('LABEL/NAME.','L')
            CALL AGSETI ('LABEL/SUPPRESSION.',0)
    C
            CALL AGSETC ('LABEL/NAME.','R')
            CALL AGSETI ('LABEL/SUPPRESSION.',1)
    C
            CALL AGSETC ('LABEL/NAME.','B')
            CALL AGSETI ('LABEL/SUPPRESSION.',0)
    C
    C Define the X-coordinate data and the Y-coordinate data for the first
    C curve.
    C
            DO 101 I=1,101
              XCRA(I)=REAL(I-1)/100.
              YCRA(I)=XCRA(I)*XCRA(I)
      101 CONTINUE
    C
    C Draw the first curve, in color 2.
    C
            CALL SFLUSH
            CALL GSPLCI (2)
            CALL GSTXCI (2)
            CALL EZXY (XCRA,YCRA,101,'USING TWO DIFFERENT Y AXES')
            CALL SFLUSH
            CALL GSPLCI (1)
            CALL GSTXCI (1)
    C
    C Turn the frame advance back on.
    C
            CALL AGSETI ('FRAME.',1)
    C
    C Tell AUTOGRAPH to put "nice" values at the ends of the top and right
    C axes.
    C
            CALL AGSETI ('X/NICE.',+1)
            CALL AGSETI ('Y/NICE.',+1)
    C
    C Turn off the left and bottom axes and turn on the right and top axes,
    C with labels on the right axis.
    C
            CALL AGSETI ('AXIS/LEFT/CONTROL.',0)
            CALL AGSETI ('AXIS/RIGHT/CONTROL.',1)
            CALL AGSETI ('AXIS/BOTTOM/CONTROL.',0)
            CALL AGSETI ('AXIS/TOP/CONTROL.',1)
    C
            CALL AGSETC ('LABEL/NAME.','L')
            CALL AGSETI ('LABEL/SUPPRESSION.',1)
    C
            CALL AGSETC ('LABEL/NAME.','R')
            CALL AGSETI ('LABEL/SUPPRESSION.',0)
    C
            CALL AGSETC ('LABEL/NAME.','B')
            CALL AGSETI ('LABEL/SUPPRESSION.',1)
    C
    C Define the data for the second curve.
    C
            DO 102 I=1,101
              YCRA(I)=-13.*XCRA(I)*XCRA(I)
      102 CONTINUE
    C
    C Draw the second curve, in color 3.
    C
            CALL SFLUSH
            CALL GSPLCI (3)
            CALL GSTXCI (3)
            CALL EZXY (XCRA,YCRA,101,'USING TWO DIFFERENT Y AXES')
            CALL SFLUSH
            CALL GSPLCI (1)
            CALL GSTXCI (1)
    C
    C Close GKS.
    C
            CALL CLSGKS
    C
    C Done.
    C
            STOP
    C
          END



    This archive was generated by hypermail 2b29 : Fri Apr 27 2001 - 11:40:56 MDT