Newsgroups: comp.sources.postscript From: "Tom Epperly" Subject: v02i011: trigraph - Triangular graph paper, Utility, Part01/01 Content-Type: text Followup-To: comp.sources.d Summary: Makes triangular graph paper, and can plot data points too Reply-To: "Tom Epperly" Organization: Dept. of Computer Science, Brown University Mime-Version: 1.0 Date: Mon, 27 Dec 1993 02:08:46 GMT Submitted-by: "Tom Epperly" Posting-number: Volume 02, Issue 11 Archive-name: trigraph/part01 Environment: PostScript Keywords: graph paper, triangle, triangular This program makes triangular graph paper, and it can plot 6 different styles of data points on the graph. Triangular graph paper is useful in chemical engineering and science for ternary phase equilibria plots. If you have any questions or suggestions, feel free to write. I am not sure if it is fully DSC compliant, but I tried. Following the DSC's is more difficult than writing the program. Tom #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # Contents: trigraph.ps # Wrapped by jgm@fiji on Sun Dec 26 21:05:08 1993 PATH=/bin:/usr/bin:/usr/ucb ; export PATH echo If this archive is complete, you will see the following message: echo ' "shar: End of archive."' if test -f 'trigraph.ps' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'trigraph.ps'\" else echo shar: Extracting \"'trigraph.ps'\" \(6618 characters\) sed "s/^X//" >'trigraph.ps' <<'END_OF_FILE' X%!PS-Adobe-3.0 X%%Title: Triangular graph paper plotter X%%Creator: Tom Epperly X%%CreationDate: March, 4 1992 X%%Copyright: Copyright (C) 1992 Thomas G. Epperly X%%Version: 1.0 X%%Pages: 1 X%%EndComments X% This program is free software; you can redistribute it and/or modify X% it under the terms of the GNU General Public License as published by X% the Free Software Foundation; either version 1, or (at your option) X% any later version. X% = X X% This program is distributed in hope that it will be useful, but X% WITHOUT ANY WARRANTY; without even the implied warranty of X% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU X% General Public License for more details. X X% This package is used to make ternary diagrams which are often useful X% in phase equilibria problems. You can adjust the size of the plot X% and specify whether it should be landscape or portrait. The plot is X% centered on the page size you specify. X X% I have tried to make it satisfy the Adobe Document Structuring X% Conventions, but this is harder than writing the actual code. X% Please send comments and suggestions by email to X% epperly@osnome.che.wisc.edu X X% PLUG YOUR DATA IN AT THE BOTTOM OF THIS FILE = X X X% CHANGE LOG X% 26 Oct 1993 Added comments before sending it to other X% people. Tom Epperly X X% BASIS DEFINITIONS FOR THE PLOTTING PACKAGE X%%BeginProlog X/inch { 72 mul } def X/filled true def X/unfilled false def X X% PARAMETERS THAT DETERMINE HOW THE PLOT LOOKS X X/landscape true def % for a landscape plot uncomment this line X% /landscape false def % for a portrait plot uncomment this line X X/height 7.5 inch def % the determines the size of the triangle X/pagewidth 8.5 inch def % Used to center the triangle on the page X/pageheight 11 inch def % Used to center the triangle on the page X X/gridlines 20 def % The number of grid lines on the triangle X/gridlabels true def % to have numeric labels uncomment this line X% /gridlabels false def % to surpress numeric labels uncomment this line X X/LabelFontHeight 8 def X/LabelFont /Helvetica findfont LabelFontHeight scalefont def X% the actual height of the characters is about 85% of the point size X/LabelFontHeight LabelFontHeight 0.85 mul def X% LabelFontHeight is now an approximation of the actual font height X X/labelstr 20 string def X/labelwidth 0 def X/DisplayFont /Helvetica-Oblique findfont 10 scalefont def X% DisplayFont is used to write the labels X X/xlabel (A) def % the X label X/ylabel (B) def % the Y label X/zlabel (C) def % the Z label X X/pointsize 2 def % the size of a data point X X% END OF PARAMETERS SECTION X X% PROCEDURE DEFINITIONS X Xlandscape { % if X /zx pagewidth height add 2 div def X /zy pageheight 2 div def X /yy zy height 3.0 sqrt div sub def X /yx pagewidth height sub 2 div def X /xy zy height 3.0 sqrt div add def X /xx yx def X /zangle -90 def X /yangle 150 def X /xangle 30 def X /displayangle -90 def X} X{ % else X /zx pagewidth 2 div def X /zy pageheight height add 2 div def X /yx zx height 3.0 sqrt div add def X /yy pageheight height sub 2 div def X /xx zx height 3.0 sqrt div sub def X /xy yy def X /zangle 0 def X /yangle -120 def X /xangle 120 def X /displayangle 0 def X} ifelse X X/point { % tx ty tz --> x y calculate the x y coordinates X % of a ternary point X 3 copy X zx mul exch yx mul add exch xx mul add X 4 1 roll X zy mul exch yy mul add exch xy mul add X} def X X/putlabel { % fraction --> X 0 0 moveto X 100 mul round cvi labelstr cvs dup X stringwidth pop /labelwidth exch def X labelwidth 2 div neg LabelFontHeight 2 div neg rmoveto X % clear area X gsave X 1 setgray X 0 LabelFontHeight rlineto X labelwidth 0 rlineto X 0 LabelFontHeight neg rlineto X closepath fill X grestore X show X} def X X% PROCEDURES FOR PLOTTING POINTS X% I have define routines to make circles, squares, and triangles which X% can be outlined or filled. X X/circle { % x y z filled --> MAKE A CIRCLE DATA POINT X newpath X 4 1 roll point pointsize 0 360 arc X gsave X { 0 setlinewidth fill } { stroke } ifelse X grestore X} def X X/square { % x y z filled --> MAKE A SQUARE DATA POINT X newpath X 4 1 roll X point X gsave X translate X pointsize 2 div dup moveto X 0 pointsize neg rlineto X pointsize neg 0 rlineto X 0 pointsize rlineto closepath X { 0 setlinewidth fill } { stroke } ifelse X grestore X} def X X/triangle { % x y z filled --> MAKE A TRIANGLE DATA POINT X newpath X 4 1 roll X point X gsave X translate X pointsize 2 div dup moveto X pointsize neg 0 rlineto X pointsize 2 div pointsize neg rlineto X closepath X { 0 setlinewidth fill } { stroke } ifelse X grestore X} def X%%EndProlog X%%Page: 1 1 X% DRAW THE GRAPH PAPER X X% make triangle X X0 0 1 point moveto X0 1 0 point lineto X1 0 0 point lineto closepath stroke X X% put corner labels X XDisplayFont setfont Xgsave X 0 0 1 point translate X zangle rotate 0 7 translate displayangle zangle sub rotate X 0 0 moveto X zlabel stringwidth exch -2 div exch rmoveto X zlabel show Xgrestore Xgsave X 0 1 0 point translate X yangle rotate 0 7 translate displayangle yangle sub rotate X 0 0 moveto X ylabel stringwidth exch -2 div exch rmoveto X ylabel show Xgrestore Xgsave X 1 0 0 point translate X xangle rotate 0 7 translate displayangle xangle sub rotate X 0 0 moveto X xlabel stringwidth exch -2 div exch rmoveto X xlabel show Xgrestore X X% put grid lines and labels if requested X XLabelFont setfont Xgsave X 0.6 setgray X 0.25 setlinewidth X 1 1 3 { % for X 1 1 gridlines 1 sub { % for X gridlines div X dup dup neg 1 add 0 3 5 index roll point moveto X dup neg 1 add 0 exch 3 4 index roll point lineto stroke X } for X pop X } for X gridlabels { % if X 1 1 gridlines 1 sub { % for X gridlines div X gsave X dup dup neg 1 add 2 div dup point translate X xangle rotate putlabel X grestore X } for X 1 1 gridlines 1 sub { % for X gridlines div X gsave X dup dup neg 1 add 2 div dup 3 1 roll point translate X yangle rotate putlabel X grestore X } for X 1 1 gridlines 1 sub { % for X gridlines div X gsave X dup dup neg 1 add 2 div dup 3 2 roll point translate X zangle rotate putlabel X grestore X } for X } if Xgrestore X X% END OF BASIC TERNARY LIBRARY X% ALL THAT FOLLOWS BELOW IS JUST AN EXAMPLE X% Replace the following example data points with your data. X X% EXAMPLE DATA X0.9 0.05 0.05 filled circle % plot a filled circle at 0.9, 0.05, 0.05 X0.3 0.23 0.47 unfilled circle % plot an unfilled circle X0.1 0.1 0.8 filled square % etc. = X X0.2 0.3 0.5 unfilled square X0.7 0.15 0.15 filled triangle X0.6 0.23 0.17 unfilled triangle X Xshowpage % Remember the showpage X%%EOF END_OF_FILE if test 6618 -ne `wc -c <'trigraph.ps'`; then echo shar: \"'trigraph.ps'\" unpacked with wrong size! fi # end of 'trigraph.ps' fi echo shar: End of archive. exit 0