Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!ames!skipper!elxsi!maine From: maine@elxsi.dfrf.nasa.gov (Richard Maine) Newsgroups: comp.lang.fortran Subject: Re: Plotting Algorithm needed Message-ID: Date: 7 Aug 90 18:11:45 GMT References: <2626.26becefa@csc.anu.oz> Sender: news@skipper.dfrf.nasa.gov Organization: NASA Dryden, Edwards, Cal. Lines: 75 In-reply-to: rsc503@csc.anu.oz's message of 7 Aug 90 14:23:54 GMT Ian Jamie asked about plot scaling routines. I tried email, figuring the reply didn't really merit a post. But my mailer can't find his system (probably has to do with it being in Austrailia), so suppose I`ll break down and post it. Here's my plot scaling routine. Nothing fancy, but it works fine for me. Do with it what you like; it is not copyrighted. subroutine scale3(xmin,xmax,axlen,expand,amn,asc,ticdst) c Richard Maine. 9 Feb 86. c determine reasonable plotting scales. c******************** common. c I normally have something like the following in an 'include' here. c Expanded by hand in this copy. c Also commented out for ANSI conformance. c implicit none c******************** interface. c xmin,xmax(input): data min and max values which must fit on scale. c axlen(input): axis length in cm or other scaled units. c Reasonable results are not guaranteed if axlen .lt. 2. c expand(input): can tic interval be expanded? c amn(output): minimum value on scaled axis. c asc(output): axis scale in units/cm. A scale of -999. indicates c xmin ge xmax c ticdst(output): interval between tics in cm. c Will always be 2 if expand is false. double precision xmin,xmax,axlen,amn,asc,ticdst logical expand c******************** externals. intrinsic log10,nint,anint c******************** local. integer nfacs parameter (nfacs=5) integer i,nTics double precision facs(nfacs),evencm,upercm,expon save facs data facs/1.,2.,5.,10.,20./ c--------------------------- executable code -------------------------- ticdst = 2. if (xmax.le.xmin) then amn = xmin asc = -999. else evencm = 2. if (xmin.lt.0. .and. xmax.gt.0. .and. axlen.lt.4.) evencm=1. upercm = (xmax-xmin)/axlen expon = 10.**nint(log10(upercm)-.5) do 100 i = 1 , nfacs asc = facs(i)*expon amn = asc*evencm*anint(xmin/(asc*evencm)-.499) if (amn+axlen*asc .ge. xmax) go to 200 100 continue 200 continue if (expand) then nTics = (xmax-amn)/(ticdst*asc) + .99999 ticdst = axlen/nTics asc = asc*2./ticdst endif endif return end -- Richard Maine maine@elxsi.dfrf.nasa.gov [130.134.64.6]