Re: Help with 1993 Version of PlotChar and AutoGraph

From: Dave Kennison (kennison AT unknown)
Date: Thu Jun 29 1995 - 10:36:59 MDT


(Note: Since others may be interested in this question and answer, I am taking
the liberty of posting it to "ncarg-talk".)

> I've been working with the AutoGraph package and have run into a
> stumbling block that prevents my supervisor and I from being able to produce
> publication quality fonts directly from NCAR plots. The problem stems from
> not being able to access the appropriate fontcap databases with the PlotChar
> routines. Although, as indicated in the manuals, the PWRITX() routine is
> available it does not support italicized fonts and includes only sketchy
> details on how you would use it to produce more appropriate numeric labels
> i.e. zeros without slashes.
>
> It seems that the superior flexibility of the PlotChar package would
> easily handle such things. However, as stated in July 10, 1992 edition of the
> AutoGraph manual, such a marriage of functionality is not possible. So, I was
> wondering if either any work had been done with PlotChar in the past few years
> in order to make it compatible or if there is any information that you could
> give me that might help us acheive publication quality fonts from PWRITX().
>
> Any help you could give would be appreciated. Thanks.

The following program includes a version of the AUTOGRAPH routine AGPWRT
which, just by being compiled with the program, replaces the default one in
the NCAR Graphics binary libraries. It calls the PLOTCHAR routine PLCHHQ.

This works pretty well, but there is one catch: since AUTOGRAPH doesn't
know that PLCHHQ is being called, its estimate of the size of a character
string written by a call to AGPWRT is based on the number of characters
in the FORTRAN character variable passed to AGPWRT. If that string
includes a lot of PLOTCHAR function codes, the size estimate may be too
large, in which case AUTOGRAPH will try to shrink it to fit and may shrink
it too much. (Really, AUTOGRAPH needs to be updated to use the text-extent
capabilities of PLOTCHAR.)

I hope this routine will help with your immediate problem.

Program follows:

      PROGRAM TESTIT
        DIMENSION XCRA(101),YCRA(101)
        CALL OPNGKS
        CALL PCSETC ('FN','TIMES-ROMAN')
        CALL ANOTAT ('X-AXIS LABEL','Y-AXIS LABEL',0,0,0,0)
        DO 101 I=1,101
          XCRA(I)=100.+REAL(I-1)/100.
          YCRA(I)=100.+(REAL(I-1)/100.)**2
  101 CONTINUE
        CALL EZXY (XCRA,YCRA,101,'LABEL FOR THE PLOT')
        CALL CLSGKS
        STOP
      END

      SUBROUTINE AGPWRT (PX,PY,CS,NC,IS,IO,IC)
C
        CHARACTER*(*) CS
C
C This subroutine enables one to use PLCHHQ from AUTOGRAPH. The results
C should be reasonably good, as long as nothing too fancy is tried.
C
C The basic notion of the routine is that calls to it with IC zeroed,
C implying that the string is to be centered on the point (PX,PY), may
C simply be passed directly to PLCHHQ without change and without much
C fear of problems caused by circumventing AUTOGRAPH's checks for labels
C that overlap. Calls to it with IC non-zero, implying that the left
C or right end of the label is to be placed at (PX,PY) must be handled
C differently: One character at a time is passed to PLCHHQ.
C
C What this means for the user is that function codes may appear in the
C x- and y-axis labels, in the graph label, and in any other label which
C has the centering parameter zeroed. A label in which lots of function
C codes are used may look very long to AUTOGRAPH and cause it to shrink
C the character size for the label in order to prevent what it thinks is
C a potential overlap problem. If this happens, see the consultants.
C
C CH holds single characters of CS.
C
        CHARACTER*1 CH
C
C If the centering option is zero, use PLCHHQ to do the whole string.
C
        IF (IC.EQ.0) THEN
          CALL PLCHHQ (PX,PY,CS(1:NC),REAL(IS),REAL(IO),0.)
          RETURN
        END IF
C
C Otherwise, use PLCHHQ to produce one character at a time.
C
        CALL GETSET (F1,F2,G1,G2,X1,X2,Y1,Y2,LL)
C
        XS=FLOAT(IS)*COS(.017453292519943*FLOAT(IO))*(X2-X1)/
     + FLOAT(KFPX(F2)-KFPX(F1))
        YS=FLOAT(IS)*SIN(.017453292519943*FLOAT(IO))*(Y2-Y1)/
     + FLOAT(KFPY(G2)-KFPY(G1))
C
        FX=PX
        FY=PY
C
        IF (IC.GT.0) THEN
          FX=FX-FLOAT(NC)*XS
          FY=FY-FLOAT(NC)*YS
        END IF
C
        FX=FX-.5*XS
        FY=FY-.5*YS
C
           DO 101 I=1,NC
           FX=FX+XS
           FY=FY+YS
           CH=CS(I:I)
           CALL PLCHHQ (FX,FY,CH,REAL(IS),REAL(IO),0.)
  101 CONTINUE
C
        RETURN
C
C REVISION HISTORY -----------------------------------------------------
C
C December, 1984 First put on XLIB. Adapted from AGUSEPWRX.
C
C June, 1987 Modified to be GKS-compatible.
C
C August, 1987 Took out comments about XLIB.
C
C April, 1994 Modified to call PLCHHQ instead of PWRITX.
C
C ----------------------------------------------------------------------
      END



This archive was generated by hypermail 2b29 : Wed Jun 28 2000 - 09:40:25 MDT