%!PS % Custom Engineering Graphs: A log log display % ================================== % by Don Lancaster % Copyright c 2006 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % An example of using my Gonzo Utilities to do a custom engineering graph. % Detailed example does a scatterplot on a 3x3 log graph. % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % This may be freely downloaded from http://www.tinaja.com/post01.asp#gonzo % To activate after obvious location mods, uncomment ONE of the following two lines: (C:\\Documents and Settings\\don\\Desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % Plus the next line when Gonzo is to be activated... gonzo begin ps.util.1 begin nuisance begin % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % To use this program, you modify your values and save it as an ordinary ASCII % textfile. That file is then sent to Acrobat Distiller for coversion to a .PDF % file format. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%% Fixzed Input Data %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /backgroundcolor {0.8 1 1} store % background color of graph /graphlinecolor {0 0.8 0.8}store % line color of graph /datadotcolor {0.3 0.3 0.3} store % dot color % loglines establishes the fine line detail of the log plots % always refers to a 1,1 lower left axis and NOT to the actual % scaled data values /loglines [ 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 200 300 400 500 600 700 800 900 1000 ] store /xdatascale 0.1 store % scale factor to make left data = 1 /ydatascale 10 store % scale factor to make bottom data = 1 /xaxisname (TREES PER ACRE) store % x axis label /yaxisname (TREE DIAMETER IN INCHES) store % y axis label /xnums [(10) (100) (1000) (10K)] store % scaled x axis data /ynums [(0.1) (1.0) (10) (100) ] store % scaled y axis data /maintitle (HUALAPAI TIMBER ALLOTMENT\n( T20N R15E ) ) store % main title % /inputdata may be cut and pasted here or run as a separate textfile % below. Format is an array of [ x0, y0, x1, y1, .... xn, yn ] data % values. Limited to a maximum of 32767 data value pairs. Data is % ACTUAL values, not graph scaled ones. /inputdata [ 30.634 0.3678 30 3 30 30 300 0.4 300 4 300 40 3000 0.5 3000 5 3000 50 100 {90 random 10 add 10 mul 90 random 10 add 10 div } repeat % fake dense data ] store % Note: fonts must be defined BELOW and AFTER grid is established. % Availability of STONE font is recommended for this demo. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%% File Read Input Data %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Any and all of the above data may optionally be read from a textfile. % If used, be sure to use a DOUBLE reverse % slash every time you want a single one in a PostScript string. % Be sure to provide complete, correct, and accurate location for access. /datafilename (C:\\Documents and Settings\\don\\Desktop\\trees\\tree1.txt) store % Uncomment the following line ONLY if external data is to be disk read... % datafilename run % run additional data from external file. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% Low Level Graph Creating Code %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % /makeagrid establishes the grid size. Each 10 x 10 area will be one % decade. Also puts down edges and background of log display area /makeagrid {100 100 10 setgrid % establish xposn yposn size grid /cstretch 0.01 store % adjust font to grid /sstretch 0.01 store backgroundcolor setrgbcolor % paint background. Comment out 0 0 mt 30 pu 30 pr 30 pd % or use [1 1 1] for white closepath fill graphlinecolor setrgbcolor % paint decades heavier line2 1 setlinecap 1 setlinejoin [ {-0.3 0 mt 30.3 r}10 4 ] yrpt % [{action} spacing repeats ] [ {0 -0.3 mt 30.3 u}10 4 ] xrpt } store % /make3x3log provides the inside detail for the log graphs. Both axes % done separately just in case semilog is later needed /make3x3log { line1 % thin line 0 1 loglines length 1 sub % draw verticals {/ptr exch store loglines ptr get log 10 mul 0 mt 30 u } for 0 1 loglines length 1 sub % draw horizontals {/ptr exch store loglines ptr get 0 exch log 10 mul mt 30 r } for } store % /plotdata scales and plots the data points from the inputdata array /plotdata { datadotcolor setrgbcolor % set dot color 0 2 inputdata length 2 sub % go through plotdata list {/ptr1 exch store % save location inputdata ptr1 get % get x value xdatascale mul log 10 mul inputdata ptr1 1 add get % get y value ydatascale mul log 10 mul mt dot % and plot dot } for } store % /addaxis lables the axes /addaxis { /font1 /StoneSans-Bold 0.85 gonzofont % numeric value font /font2 /StoneSans-Bold 1.2 gonzofont % title value font font1 % pick numeric font black % and color 0 1 xnums length 1 sub { % show the x axis nums /ptr2 exch store ptr2 10 mul -1.5 xnums ptr2 get cc } for 0 1 ynums length 1 sub { % show the y axis nums /ptr2 exch store -0.9 ptr2 10 mul 0.3 sub ynums ptr2 get cr } for font2 15 -3.5 xaxisname cc gsave -3.5 15 translate 90 rotate 0 0 yaxisname cc grestore } store % /addboiler provides the main graph name, can later extensively annotate. /addboiler { /font3 /StoneSans-Bold 2 gonzofont % title value font font3 /yinc 2.2 store 15 35 maintitle cc % print main title } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% High Level Graph Creating Code %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This routine combines the needed steps for the complete log log plot. /makealogloggraph { makeagrid % sets up grid make3x3log % draws log graph addaxis % letters the axes plotdata % plots data points addboiler % adds title and desc } store % temp defaults. uncomment for debug % /make3x3log {} store % /addaxis {} store % /plotdata {} store % /addboiler {} store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% Actual Graph Creator %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This routine actually draws the graph makealogloggraph showpage % EOF