        SUBROUTINE DF_AXES(LUS,XLINLOG,YLINLOG,XUNIT,YUNIT,
     .  XFORMAT,YFORMAT,BUFFER)
C
C----------------------------------------------------------------------
C.IDENTIFICATION: Subroutine DF_AXES
C.LIBRARY:        XASGRAPH
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       0.0 - 13 Oct 93 - Prototype
C                 0.1 - 01 Jul 97 - annotate Y "divided by X"
C.PURPOSE:        plot DeFault AXES
C.SYNTAX:         CALL DF_AXES(LUS,....)
C.PARAMETERS:     INTEGER LUS(2)     : the graphics logical units
C                 CHAR*3 X|YLINLOG   : LIN|LOG flags
C                 CHAR*(*) X|YUNIT   : name of XAS column with axis units
C                 CHAR*(*) X|YFORMAT : format for numbers on axes
C                 CHAR*(*) BUFFER    : work buffer provided by caller
C----------------------------------------------------------------------
C
C
C       plot default axes in X|YLINLOG mode annotating their labels
C       with the file keywords contained in XUNIT,YUNIT 
C
        INTEGER   LUS,I,IERR,J,TRUE_LENGTH
        CHARACTER XLINLOG*(*),YLINLOG(*),YLAB*5
        CHARACTER XUNIT*(*),YUNIT*(*),BUFFER*(*),WORK*8,SAVE*8
        CHARACTER XFORMAT*(*),YFORMAT*(*)
        REAL      R
        LOGICAL   DIVIDEBYBIN
        INCLUDE   'pencommon.inc'
C
        CALL Y_COLOUR(LUS,PENCOMMON_AX)
C
C       draw frame
C
*       CALL Y_MOVE(LUS,PENCOMMON_XWL,PENCOMMON_YWL)
*       CALL Y_DRAW(LUS,PENCOMMON_XWU,PENCOMMON_YWL)
*       CALL Y_DRAW(LUS,PENCOMMON_XWU,PENCOMMON_YWU)
*       CALL Y_DRAW(LUS,PENCOMMON_XWL,PENCOMMON_YWU)
*       CALL Y_DRAW(LUS,PENCOMMON_XWL,PENCOMMON_YWL)
C
C       set up axes and draw tics and numbers (and labels...)
C
        CALL Y_COORDINATES(LUS,1)    
        CALL Y_MOVE(LUS,0.0,0.0)                       
        CALL Y_DRAW(LUS,1.0,0.0)                    
        CALL Y_DRAW(LUS,1.0,1.0)                      
        CALL Y_DRAW(LUS,0.0,1.0)                       
        CALL Y_DRAW(LUS,0.0,0.0)                         
C      
C       x bottom axis
        CALL LB_AXIS('X',0.0,0.0,XLINLOG,1.0,
     .  PENCOMMON_XWL,PENCOMMON_XWU,'EXACT',10)
        CALL LB_TICS(LUS,0.02) 
        CALL LB_NUMBER(LUS,XFORMAT,'CENTRED','NORMAL')
C-->    in future use LB_LABEL to plot label
C
C       x top axis
        CALL LB_AXIS('X',0.0,1.0,XLINLOG,1.0,
     .  PENCOMMON_XWL,PENCOMMON_XWU,'EXACT',10)
        CALL LB_TICS(LUS,-0.02) 
C
C       y left axis
        CALL LB_AXIS('Y',0.0,0.0,YLINLOG,1.0,
     .  PENCOMMON_YWL,PENCOMMON_YWU,'EXACT',10)
        CALL LB_TICS(LUS,0.02) 
        CALL LB_NUMBER(LUS,YFORMAT,'CENTRED','ROTATED')
C-->    in future use LB_LABEL to plot label
C
C       y right axis
        CALL LB_AXIS('Y',1.0,0.0,YLINLOG,1.0,
     .  PENCOMMON_YWL,PENCOMMON_YWU,'EXACT',10)
        CALL LB_TICS(LUS,-0.02) 
C
C       x axis label
C-->    this should depend on TUNIT1 (or TUNITn of TFORMn=BOUNDARY)
        CALL H_READ_KEYWORD(XUNIT,BUFFER,'unspecified',IERR)
        IF(BUFFER.NE.'unspecified')THEN
          I=TRUE_LENGTH(BUFFER)
          CALL Y_MOVE(LUS,0.45,-0.09)
          CALL Y_TEXT(LUS,BUFFER,7)
          SAVE=BUFFER
        ENDIF  
C       y axis label (vertical text sic!)
C-->    very very rough y label unitl xwserver does not support orientation
C-->    this should depend on TUNIT3 (or TUNITn of TFORMn=DATA)
C-->    allow TUNITn to point to anoterh TUNITm
C
C     new option to divide cts/s or cts by bin width (bin or kev) for plotting
        CALL GET_GLOBAL_DEFAULT('COUNTUNITS','Undivided',BUFFER)
        CALL UPCASE(BUFFER)
        DIVIDEBYBIN=BUFFER(1:1).EQ.'D'
        WORK=YUNIT
 667    CONTINUE
        CALL H_READ_KEYWORD(WORK,BUFFER,'unspecified',IERR)
        IF(BUFFER(1:1).EQ.'=')THEN
           WORK=BUFFER(2:)
           GOTO 667
        ENDIF  
        IF(BUFFER.NE.'unspecified')THEN
          J=TRUE_LENGTH(BUFFER)   
          IF(DIVIDEBYBIN)THEN
            BUFFER(J+1:)='/'//SAVE
            J=TRUE_LENGTH(BUFFER)   
          ENDIF
          R=0.5+ (MIN(J,20)*0.05)/2
          DO 333 I=1,J
           CALL Y_MOVE(LUS,-0.15,R-0.05*I)
           CALL Y_TEXT(LUS,BUFFER(I:I),7)
 333      CONTINUE
        ENDIF
        RETURN
        END 
