SUBROUTINE AXIS(X,Y,LABEL,NCH,AXLEN,THETA,AXMIN,AINC) C C X,Y(real)=the coordinates in inches of the starting point C of the axis. C LABEL(integer)=a Hollerith string that will be used as the axis C label,it is centered and drawn in 0.25 inch high letters C NCH(integer)=number of characters in LABEL.If pos.,label,scale, C & tick marks are drawn on CCW side of axis. C If neg.,they are placed on the CW side. C AXLEN(real) =The length of the axis in inches. C S is also used to indicate that only integers are to C be used on the axis.This is done by making S negative. C THETA(real)=The angle in degrees from the +X direction that C the axis is drawn.=0. implies a horizontal axis reading C left to bottom. =90.implies a vertical axis reading C bottom to top.If -ve all axis values will be plotted C perpendicular to the axis (except for the title). C AXMIN(real)=the minimum value shown on the axis. C AINC(real)=the scale increment per inch on the scale. C NN(integer)=specifies the number of digits after the decimal point C on numeric lettering. C To keep with standard CALCOMP format,NN is internally C defined as 2 decimal places.The decimal place and the C decimal point can however,be supressed by using -ve S. C C NOTE: Because of the large step between character sizes C centering of characters at angles other than 0,90,180,and 270 C gives problems. I've left them as is. C BYTE LABEL(1) BYTE AXLBL(81),EXPON(6) INTEGER I DATA EXPON(1)/32/,EXPON(2)/120/,EXPON(3)/32/,EXPON(4)/49/ + ,EXPON(5)/48/,EXPON(6)/0/ DATA AXLBL/81*32/ !just a bunch of blanks PI=3.141592654 TICLEN=.15 !length of the tick marks HT=.15 !character height NN=2 !number of decimal places C C ============================================================================ C C If the numbers can be represented as integers DO IT- it looks cleaner C IF(AXLEN.LT.0.AND.ABS(AINC).GE.1.AND.(AINC-AINT(AINC)).EQ.0.)NN=-1 XMIN=AXMIN XLENG=ABS(AXLEN) !axis length STH=SIGN(1.,THETA) !get the sign of THETA:perp.or par. ISG=ISIGN(1,NCH) !get the sign of NCH:CCW or CW side ATHETA=ABS(THETA)+360. !make sure the angle is positive NCH=IABS(NCH) !positive number of characters NTICKS=INT(XLENG) !number of tick marks RAD=ATHETA*PI/180. !convert the angle to radians ORTH=RAD+FLOAT(ISG)*PI/2. !find the orthogonal angle CO=COS(ORTH) !let's just do these operations once SO=SIN(ORTH) CR=COS(RAD) SR=SIN(RAD) TXEND=(TICLEN-.05)*CO !x end point of the tick mark TYEND=(TICLEN-.05)*SO !y end point of the tick mark TXL=(TICLEN+.05)*CO TYL=(TICLEN+.05)*SO C C ============================================================================ C C Do we need to use exponential format? Let's find out. C EXP=0. DABS=ABS(AINC) IF(DABS.GE..01.AND.DABS.LE.100.)GOTO 5 1 IF(DABS.LT..01)GOTO 4 2 IF(DABS.GT.100.)GOTO 3 GOTO 5 3 DABS=DABS*.1 XMIN=XMIN*.1 EXP=EXP+1. GOTO 2 4 DABS=DABS*10. XMIN=XMIN*10. EXP=EXP-1. GOTO 1 5 DABS=SIGN(DABS,AINC) XORG=X !store x in dummy variable YORG=Y !store y in dummy variable TICSP=XLENG/FLOAT(NTICKS) !find the tick spacing C C ========================================================================== C C First,draw the axis and its associated tick marks C IFL=3 !pen down DO 8 I=1,NTICKS+1 !now plot the tick marks IF(I.GT.1)IFL=2 !pen up for the 1st position CALL PLOT(XORG,YORG,IFL) !move to the first point XT=XORG+TXEND !find the X,Y end point of the tick YT=YORG+TYEND ! CALL PLOT(XT,YT,2) !draw the tick mark CALL PLOT(XORG,YORG,1) !move back along the tick mark XORG=XORG+TICSP*CR !calculate the next X position 8 YORG=YORG+TICSP*SR !calculate the next Y position C C =========================================================================== C C Now go back and label the tick marks C XORG=X !store x in dummy variable YORG=Y !store y in dummy variable ANG=ATHETA*ISG !make sure ANG has the right sign IF(STH.LT.0.)ANG=-ISG*(ATHETA-90.)!for perpendicular values only HEIGHT=STH*-HT !make sure HEIGHT has the right sign DO 20 I=1,NTICKS+1 TX=XORG+TXL !X point at tick end with offset TY=YORG+TYL !Y point at tick end with offset IF(STH.LT.0.AND.ABS(THETA).EQ.90.)TY=TY-HT/2. CALL NUMBER(TX,TY,HEIGHT,XMIN,ANG,NN)!now write the value XMIN=XMIN+DABS !increment the value XORG=XORG+TICSP*CR !calculate the next X position 20 YORG=YORG+TICSP*SR !calculate the next Y position C C ============================================================================ C C Now let's center the axis title C HITT=HT*1.6 ATHETA=ATHETA*ISG HAFWAY=XLENG/2. SXT=X+HAFWAY*CR SYT=Y+HAFWAY*SR TOFF=HITT*2.0 IF(STH.LT.0.)TOFF=HITT*4. TXT=SXT+TOFF*CO !x end point of the tick mark TYT=SYT+TOFF*SO !y end point of the tick mark LABEL(NCH+1)=0 !null byte terminator IF(EXP.NE.0.)NCH=NCH+5 IF(EXP.EQ.0.)CALL SCOPY(LABEL,AXLBL,NCH) IF(EXP.NE.0.)CALL CONCAT(LABEL,EXPON,AXLBL,NCH) AXLBL(NCH+1)=0 CALL SYMBOL(TXT,TYT,-HITT,AXLBL,ATHETA,NCH) IF(EXP.EQ.0.)RETURN HHT=ABS(HITT)*.7 ATHETA=ABS(ATHETA) CALL SPMODE(1) CALL NUMBER(0.,0.,HHT,EXP,ATHETA,-1) CALL SPMODE(0) RETURN END