<<< Plotting Program >>> User's Manual. Glossary -------- (One good picture is worth thousand words....) 1) When we say "x-axis horizontal" the other say "landscape", when we say "x-axis vertical" the others say "portrait": .-----------------------------. .------------------. | | | | | | | | | | | | | Landscape | | Portrait | | | | | | | | | | | | | `-----------------------------' | | (x-axis parallel to the longer | | side of the drawing paper) | | `------------------' (x axis parallel to the shorter side of the drawing paper) History: On the "platen" plotters the platen was always as the "Landscape" so the x axis was always parallel to the longer side of the paper (when standing in the front of the plotter) and if somebody wanted graph in the "Portrait" mode then the x axis was vertical and the y axis horizontal. 2) axis, labels, legend, title, and notes: ---------------------------------- axis -----+-----+-----+-----+-----+---- axis with ticks -----+-----+-----+-----+-----+---- axis with ticks and 1 2 3 4 5 labels -----+-----+-----+-----+-----+---- axis with ticks, 1 2 3 4 5 labels, and this is axis legend legend (centered) -----+-----+-----+-----+-----+---- axis with ticks, 1 2 3 4 5 labels, this is axis legend legend (centered), and Fig. 1: TEST PLOT plot title (left justified) -----+-----+-----+-----+-----+---- axis with ticks, 1 2 3 4 5 labels, this is axis legend legend (centered), Fig. 1: TEST PLOT plot title (right justified), and Dotted line represents .... notes (always left justified) Dashed line represents .... The "notes" are allowed only in the x-axis vertical plots (so called "por- trait"). The plot title is always placed below the x-axis and can be either centered or left justified (with the y-axis). The axis labels are (sort of) centered around the corresponding tick. The default plot is the "x-axis horizontal". The same plot can be drawn with "x-axis vertical" - no RO-tate function is used. -----===<<#>>===----- Simplified program flow chart for PLOT.BAS ------------------------------------------ .------------------------. | SELECT PLOTTING OPTION | | OR EXIT | `-----------v------------' | V .------------. | DATA INPUT | `-----v------' | V .----------------. .---------------. | Option 4 only: |<--------| CHECK OPTIONS |<---------------------. | DATA TO ENTER? | `-------v-------' | `-----v----v-----' | | NO | | YES | | | `---------------------->O-----------------. | | | | | | V V | | .--------------. .---------------. | | | TYPE IN DATA | | USE DATA FILE | | | `-------v------' `-------v-------' | | | | | | V V | | .-----------------------------. | | | REVIEW AND CORRECT THE DATA | | | `-----------------------------' | | | | | V | | .--------------------. YES | | | MORE DATA TO ENTER |-------------------' | `---------v----------' | | | | NO | V | NO .----------------. | .-----| Option 2 or 3? | | | `----------------' | | | | | | YES | | V | | .-------------------. | | | DO CALCULATION OF | | | | COEFFICIENTS | | | `---------v---------' | | | | | | | V V | .------------------------------------. `--------->| CONTINUE WITH GRAPHICS SCREEN PLOT | `------------------------------------' Simplified program flow chart for PLOT01.BAS -------------------------------------------- .-----------------. | GRAPHICS SCREEN | | ROUTINES | `--------v--------' | V .-----------------. NO | PLOT ON SCREEN? |----------------------. `--------v--------' | | | | YES | V | .-----------------. | .--------->| SCREEN PLOTTING |<---------. | | | AREA SETUP | | | | `--------v--------' | | | | | | | V | | | .-----------------. | | | | PLOTTING LIMITS | | | | | SETUP | | | | `--------v--------' | | | | | | | V | | | NO .----------------. | | `-----------| READY TO PLOT? | | | `----------------' | | | | | | YES | | V | | .------. | | | PLOT | | | `------' | | | | | V | | .--------------------. YES | | | MORE DATA TO PLOT? |--------' | `--------------------' | | | | NO | V | .---------------------------. | | CHECK THE PLOTTING OPTION | | | PLOT ON PLOTTER? | | `---------------------------' | | | | | NO | YES | V V | .---------------------. .------------------. | | DATA ENTRY ROUTINES | | GRAPHICS PLOTTER |<-----' `---------------------' | ROUTINES | `------------------' Simplified program flow chart for PLOT02.BAS -------------------------------------------- .------------------. | GRAPHICS PLOTTER | | ROUTINES | `--------v---------' | V .-------------------. | SELECT OUTPUT AND | | SET FLAGS | `---------v---------' | V .---------------. .------->| PLOTTER SETUP |<---------------------. | | ROUTINES | | | `-------v-------' | | | | | | | | V | | .-----------------. | | | PLOTTING LIMITS | | | | SETUP | | | `--------v--------' | | | | | V | | NO .----------------. | `--------| READY TO PLOT? | | `-------v--------' | | YES | | | .------------------^---------------. | | | | V V | .-----------. .--------------------. | | DATA FILE | | SETUP SERIAL PORT | | `-----v-----' | INITIALIZE PLOTTER | | | `----------v---------' | | | | V V | .-----------------. .------. | | COMMAND STRINGS | | PLOT | | | TO DATA FILE | `--v---' | `--------v--------' | | | | | `-----------------v----------------' | | | V | .-----------------------------------. YES | | MORE DATA TO PLOT OR REPEAT PLOT? |------------' `-----------------------------------' | NO V .------------------. | CHAIN DATA ENTRY | | ROUTINE | `------------------' -----===<<#>>===----- 1. Introductory notes. ------------------- The whole program consists of three sub-programs: PLOT.COM - routines to enter experimental data and data manipulation, PLOT01.COM - routines for graphics screen, PLOT02.COM - routines for graphics plotter. In addition some utilities are provided with the program. These are: SDUMP.BAS - a program to dump the graphics screen into a data file, SLOAD.BAS - a program load the graphics screen from a data file, RDPLT.BAS - a program to read a file containing the command lines for the Hewlett-Packard plotter and send these through a serial port to the plotter (with xon/xoff handshake), PLOT04.BAS - an example program to create a file for the user define func- tion plot. This program creates data file PLOT04.DAT which will be read by PLOT01.COM and PLOT02.COM. The source codes are supplied for these utilities and can easily be changed to suit the user's system. The following files will be created during the program run: PLOT.FLG - communication flags for PLOT*.COM files; random access, binary file, record length 2 bytes (integers), max 12 records, PLOT.$$$ - temporary data file created by PLOT.COM; random access, binary, record length 4 bytes (real numbers), max 640 records, PLOT0?.DAT - (? stands for 2 or 3) temporary data file created by PLOT.COM; random access, record length 4 bytes (real numbers), max 3600 records, PLOT0?.SET - (? stands for 2 or 3 or 4) temporary data file created op- tionally by either PLOT01.COM or PLOT02.COM containing settings for the graphics (screen and plotter); random access, binary, 1 record 40 bytes of length. PLOT03.DOC - temporary file created by PLOT.COM; sequential, ascii, vari- able record length, max 8 records, containing coefficients for the linear regression analysis. More about all these files in PLOT.bas, PLOT01.bas and PLOT02.bas. The source code is for Microsoft Basic Compiler version 5.3 and has to be compi- led with an option /C (relax line numbering). Unless you have al least 60kb of available TPA do not use switch /O. All three files, PLOT.BAS and PLOT01.BAS and PLOT02.BAS, have to be compiled the same way. For those who would like to use the Basic interpreter the following modifications have to be made: 1) All comment lines have to be removed. 2) Line numbers (labels) have to be added. This should not be very difficult. 3) The arguments of the CHAIN statements have to be changed. The program when compiled as supplied will run on a system comprising of 6MHz Z80B CPU, Televideo terminal, graphics card addressable at 240 (data) and 241 (status) using graphics codes compatible with Microangelo Graphics Card , serial Z80-SIO port addressable at 132 (data) and 133 (status) with CTC at 137 (if baud change is required) to which a plotter which uses the Hewlett-Packard Graphics Language (HPGL) is attached. (Note: the addresses given are decimal.) The program uses direct access to the port and does x-on/x-off handshake. The routine for the 8251 UART is also supplied (commented out). All is quite well documented in the source files. The minimum requirement is a terminal with the Televideo screen attributes for the program to run as is without any modification. The output has then to be directed to a data file, which is sequential ASCII file, which will contain all the commands strings that would be otherwise send to a plotter. The user can later transfer the file into a system with a facility to plot using HPGL (laser printer with HP card). -----===<<#>>===----- 2. Compiling the program. ---------------------- When listing the source codes use the Compressed Mode (15 characters per inch) on your printer. The lines are 120 characters long. Suggested compiling (syntax is for the BASCOM version 5.3 and Link-80 version 3.44): a) for systems with less than 60kb of TPA available (BRUN module required) BASCOM PLOT=PLOT/C/Z BASCOM PLOT01=PLOT01/C/Z BASCOM PLOT02=PLOT02/C/Z L80 PLOT,PLOT/N/E L80 PLOT01,PLOT01/N/E L80 PLOT02,PLOT02/N/E b) for systems with more than 60kb of TPA (stand alone command files, BRUN mo- dule not required) BASCOM PLOT=PLOT/C/Z/O BASCOM PLOT01=PLOT01/C/Z/O BASCOM PLOT02=PLOT02/C/Z/O L80 PLOT,PLOT/N/E L80 PLOT01,PLOT01/N/E L80 PLOT02,PLOT02/N/E When successfully compiled, the .REL files can be deleted, .BAS files archived, backup copies of .COM files made, and the program can be run. The program with all associated data files needs about 130kb of disk space. -----===<<#>>===----- 3. INSTRUCTIONS AND EXPLANATIONS. ------------------------------ NOTE: During the program run only a limited checking is provided on users en- tries and no "sophisticated" error routines are employed. I have considered that the user is intelligent enough. The famous BASIC's "Redo from start" will appear after erroneous entry with all its consequences - messages and prompt strings will be out of sequence on the screen. The program can be built fool- proof but at high cost of program size. 3.1. The Main Menu. -------------- The program is run by typing PLOT at the console. Note that the upper case let- ters are required for answers. The default answer will appear in parentheses like (Y) which means that pressing ENTER has the same effect as typing Y and then pressing ENTER. The user should be aware that only a limited checking is done for the correctness of answers. Assuming all is all right the following menu will appear on the screen: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ <<< Plotting Program >>> MAIN MENU Select from the following: -------------------------- 1. Plot experimental points 2. Plot experimental points and draw a smooth curve through the points using spline functions 3. Plot experimental points, do linear regression analysis and draw a regression line or curve 4. Plot user defined function through experimental points 5. Exit this program Type the number of your selection: 1 \__________________________________________________________________________/ Explanation: Choice 1: Max of 8 data sets, each max of 40 x,y-pairs, are allowed. The pro- gram will plot and, if experimental errors are supplied (as average rela- tive error or relative error of each value taken from a data file), a rec- tangle corresponding dimensionally to relative x and y errors will be drawn around each experimental point. Choice 2: Only one set of data with max of 40 x,y-pairs is allowed. The program will calculate spline functions coefficients (third degree polynomials, li- terature references about the spline functions subroutine given in PLOT.BAS file), points for spline function curve (400 points), first and second de- rivatives (of the spline functions!) and then will plot experimental points (with their relative errors if so required) and will draw a smooth curve through the points. The user can choose to plot spline curve or the first derivative or the second derivative or all three functions. Choice 3: Only one set of data with max of 40 x,y-pairs is allowed. All data entered must be non-zero and positive, and the minimum number of x,y-pairs entered is 4. A limited check on validity of data is performed but it is expected that the user is intelligent enough to know the use of regression functions. It saves time and quite a lot of coding. The program will cal- culate regression coefficients for eight models (like parabolic, hyperbo- lic, exponential, logarithmic, linear, quadratic), then it will plot expe- rimental points (with or without relative errors) and then it will draw regression function (the user can choose the function with the best fit to the data). Choice 4: Here the data entry is optional; if there are data then up to 8 sets of data with max of 40 x,y-pairs is allowed. The program will plot the data (with or without relative errors - if supplied) and then will draw user defined function from a data file which has to be prepared before this program is run. The default file name is PLOT04.DAT and the structure of the file is exactly the same as for PLOT03.DAT - described in PLOT.BAS. Here in the MAIN MENU only integers 1 to 5 will be accepted and anything else will cause the prompt "Type the number of your selection:" to appear again. When the selection is made the user is then prompted to make a choice where to plot: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ 1. Plot on the Graphics Screen 2. Plot on the plotter Type the number of your selection: 2 \__________________________________________________________________________/ Explanation: Choice 1: This selection will utilize only the graphics screen. The program is setup for the Microangelo Graphics Board (or compatible) which has data port ad- dress at 240 and status port address at 241. If your system is different and you wish to utilize these graphics routines then some or all the graphics codes in PLOT01.BAS will have to be changed. What you have to supply is: a) the way to output and input data to and from the card, (subroutine 5000), b) code for clear graphics and reset alpha cursor, (subroutine 5040), c) code to set position of alpha cursor, (subroutine 5050), d) code to set graphic cursor to given coordinates, (subroutine 5060), e) code to reset the graphics card but not to clear graphics, (subrou- tine 5070), f) code to draw a line from current position to given position, (sub- routine 5080), g) code to print a character at given position of graphics cursor, (subroutine 5090), h) code to set character mode, size, direction and video mode, (subro- utine 5100), i) codes for graphics screen dump and load, (subroutines 1550 and 1560), but if your system does not support that then simply insert "RETURN:'" after the subroutines labels), j) code for page-edit/page-display, (subroutine 6000). More details about all that in PLOT01.BAS. If you have a terminal which can also display (pixel) graphics that you will have to insert subroutine which will switch at required times graphics display and text display. Choice 2: The output will be directed either to a data file or to a plotter (using standard HPGL). The user will be prompted later in the program. Here only integers 1 or 2 will be accepted and anything else will cause the prompt "Type the number of your selection:" to appear again. When the selection is made then the program continues with the Data Entry routines. 3.2.1. Data entry routines. -------------------- As you can see we have chosen option 1, the "Experimental data plot". The se- lection menu for the data input may appear like this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ <> Plot of experimental points Select from the following: -------------------------- 1. Keyboard data entry 2. Data entry from a data file The number of your selection: 1 \_________________________________________________________________________/ Explanation: On the very first line on the screen is a header which informs about which data file is in use (left side), what is going to be plotted (middle), and the rou- tine (right side). Only two choices are displayed but in the case of plotting the user defined function there is an option of no data entry - simply by pres- sing the ENTER key. Here, if the plotting options no. 1 to 3 were chosen, only the numerals 1 or 2 are accepted and anything else will cause the prompt to be re-displayed. However, if the option no. 4 was chosen, (the "User's function plot") then an additional option is available, which is NO DATA ENTRY (plot function from a data file). Data input from the keyboard. ----------------------------- The selection was made to type-in the data. The following menu will be displayed: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points How many data pairs for plot no. 1: 10 \__________________________________________________________________________/ Explanation: Very little checking is provided here; the number of data pairs should be at least one and at most forty. less than one and more than forty will cause the prompt to be re-displayed. The use should note that for the options 2 and 3 there is a minimum of 4 data pairs to be entered. Failing that will cause the program to abort later during the calculation of the coefficients. The user will be prompted to enter each value. The data correction and review routine will follow after this routine, i. e., after each data set entered. After the last Y entry the screen may appear like this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points X( 6 ) = 6 Y( 6 ) = 36 X( 7 ) = 7 Y( 7 ) = 49 X( 8 ) = 8 Y( 8 ) = 64 X( 9 ) = 9 Y( 9 ) = 81 X( 10 ) = 10 Y( 10 ) = 100 Review and correct the data (Y/N)? Y \__________________________________________________________________________/ Explanation: Here the user has to answer by capital Y or N. Anything else will cause re- display of the prompt. The N answer will cause this routine to be skipped and the program, depen- ding on the plotting choice will either ask for more data (options to plot expe- rimental data only or to plot user defined function through experimental data) or will calculate coefficients for functions (spline functions or linear regres- sion options) to be plotted. By answering Y the data correction and review routine is started. 3.2.2. Data correction and review routine. ----------------------------------- The screen may look similar to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points Type the correct data or press RETURN! X( 1 , 1 ) = 1 ? Y( 1 , 1 ) = 1 ? .99 : : : : \__________________________________________________________________________/ Explanation: The user has a choice of entering a correction after the prompt (question mark) or pressing the ENTER key to leave the entry unchanged. After the last entry the prompt asking for data review and correction is displayed again. Note, that data pairs cannot be ADDED to the set just entered. /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points X( 1 , 2 ) = 2 ? Y( 1 , 2 ) = 4 ? X( 1 , 3 ) = 3 ? Y( 1 , 3 ) = 9 ? X( 1 , 4 ) = 4 ? Y( 1 , 4 ) = 16 ? 16.5 X( 1 , 5 ) = 5 ? Review and correct the data (Y/N)? N \__________________________________________________________________________/ This time we will answer N because we want to enter the data for the second set. On the screen will appear the prompt which has to be answered with capital Y or N: Another set (no. 2 ) to enter (Y/N)? Y It should be noted that for options to plot spline functions or regression fun- ctions only one set of data (max 40 x,y-pairs) is allowed and the program will automatically proceed with calculations of coefficients. The user, in that case, will not be prompted for another set of data. The program goes back to the data Entry Menu and the user is prompted again to select either to type the data in or to take the data from a specified data file. This time we will input the data from a data file. Data input from data file. -------------------------- /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points Select from the following: -------------------------- 1. Keyboard data entry 2. Data entry from a data file The number of your selection: 2 \__________________________________________________________________________/ The data entry from a data file was selected and the user is prompted to enter the name of that data file. It should be noted that the dat file must be of random access, binary, record length 4 bytes (real number storage space). NO checking is provided for data existence. The name of the file must be entered in the UPPER case. Again, no checking on legality of names is done here. Acco- rding to the Microsoft Basic convention, if the named file does not exist then the one is created and unwritten data are "read". Illegal filename will cause the program to abort. It is assumed here that the user is "literate" in Basic enough to know where to use upper case letters. Alternatively, rushed users may finished with a number of files with their names in lower case letters.... The screen for the data entry from a data file may appear like this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points The name of the INPUT data file: JUNK.DAT Start with the pair no.: 1 Finish with the pair no.: 10 \__________________________________________________________________________/ The structure of the data file was already mentioned. The data are read from the nominated file and after that the user is prompted to review and correct the read data (the Data correction and Review routine): /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points Review and correct the data (Y/N)? Y \__________________________________________________________________________/ The data can be reviewed: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot of experimental points Type the correct data or press RETURN! X( 2 , 1 ) = 1 ? Y( 2 , 1 ) = 1.85 ? X( 2 , 2 ) = 2 ? Y( 2 , 2 ) = 4.1 ? X( 2 , 3 ) = 3 ? X( 2 , 8 ) = 8 ? Y( 2 , 8 ) = 15.85 ? X( 2 , 9 ) = 9 ? Y( 2 , 9 ) = 18.1 ? X( 2 , 10 ) = 10 ? Y( 2 , 10 ) = 19.75 ? \__________________________________________________________________________/ And after the last entry the user is asked again: Review and correct the data (Y/N)? N This time we answer N (mind the case). Another prompt will appear: Another set (no. 3 ) to enter (Y/N)? N For the demonstration purpose two sets of data is enough. It should be mention- ed at this stage, that when the data are entered from the keyboard the user is asked whether the x-values or the y-values are the same as in the preceding set. If they are then the user does not have repeat those entries. However, if the number of data pairs does not agree then either zeros are automatically entered (when the preceding set has lower number of data pairs) or only the entries up to the stated number of the pairs are automatically entered. The user is then left with an option to review and correct the missing data. By answering N to the question about another set of data, the program will con- tinue with graphics screen routines. 3.3. Graphics Screen Plot. --------------------- When there is no more data to be entered and all the coefficients have been calculated, then the user, if his chosen plotting option was to use the plotter, will be prompted to plot on the graphics screen: Plot on Graphics Screen too (N)? Y The default answer is N (not to use the graphics screen - the user has chosen to use the graphics plotter), but by pressing Y (mind the case) the program will plot on the graphics screen first. We have pressed Y so the program will plot on the graphics screen before using the plotter. 3.3.1. Graphics Screen Plotting Area Setup. ------------------------------------ Here start setup routines for the graphics screen setup. The first setup screen will look similar to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ <> Plot of experimental points Total plotting area is 512 X 490 abs. units. The default plotting area (in abs. units): 410 X 410 X(start), abs. units: 61 X(end), abs. units: 471 Y(start), abs. units: 458 Y(end), abs. units: 458 OK (Y)? N \__________________________________________________________________________/ Explanation and notes: The term "total plotting area" means the maximum number of points (also called pixels) on the graphics screen which can be addressed. The "default plotting area" is the area on the graphics screen which is limited by the x and y axis. Labels and legend (there is only one legend allowed which also serves as the title) are outside of this area. The default answer is Y which means that by pressing ENTER (or anything else apart from N) the displayed values will be taken by the program for calcula- tions. By pressing N (mind the case) the user has an option of changing these values. There is no check on validity of the user supplied data - it is expected that when the user wants to change defaults he knows what he is doing. Two frames will be drawn on the graphics screen; one around the whole screen showing the total plotting area, and second showing the user selected area for the axis (called "default plotting area"). This routine is repeated until the user is "completely satisfied". When this is so then the program continues with selection of data sets and functions. 3.3.2. Data selection routine. ----------------------- The user is prompted to select which data set or which function to plot. The screen will appear similar to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ <> Plot of experimental points There are 2 set(s) of data. Which set to plot? 1 \__________________________________________________________________________/ Explanations: Well, we entered two sets of data earlier so we have a choice which set to plot. If the choice on the Main Menu was to plot spline functions or regression analy- sis (both selections allow only one set of experimental points) then the prompt will be different: a) spline functions plot: "Type F to plot f(x), D1 to plot f'(x), D2 to plot f''(x):" where f(x) is the spline function f'(x) is the first derivative (of the spline function) f''(x) is the second derivative (of the spline function) b) regression analysis plot: "1. Y=A+B*X " "2. Y=A+B/X " "3. 1/Y=A+B/X " "4. Y=B*X^2 " "5. Y=A*exp(B*X) " "6. Y=A*X^B " "7. Y=A+B*ln(X) " "8. Y=A+B*X+C*X^2 " "Type the number of your selected regression model:" c) user defined function: (display is the same like for the "Plot experimental points" option) 3.3.3. Plotting limits selection routine. ---------------------------------- /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ <> Plot of experimental points X(0), (user units): = 0 Y(0), (user units): = 0 X(MIN), (user units): = 1 X(MAX), (user units): = 10 Y(MIN), (user units): = 1 Y(MAX), (user units): = 100 X-divisions: = 10 Y-divisions: = 10 min of F(x), (user units): = 0 max of F(x), (user units): = 0 OK (Y/N)?N \__________________________________________________________________________/ Explanation and notes: X(0),Y(0) are the X and Y coordinates of the point of intersection of axis, F(x) is a function to be plotted; here we have chosen to plot experimental points only - that means no function to be calculated and plotted, but, the points can be connected by a line. All numerical data can be changed apart from the min and max of the function. The data for that are displayed here only for the user information to chose proper plotting limits. Here the user has to answer Y or N (mind the case) to proceed further. Answer Y if the limits are suitable and you wish to proceed with the next routine, or answer N to change the limits. By answering N to the prompt the following prompt will appear: "Type K to use keyboard, D data file for graphics screen setup:" This means that we have an option of changing limits manually (from the key- board) or take the limits from a file prepared beforehand. Since we have not prepared any file of that sort we have to select K and enter all limits manu- ally. There is no need to prepare the file because the user will be prompted to store all setup limits in a file (either default or user specified). The pro- cedure to change the limits is similar to the "Data review and correction" rou- tine. No other checking of legality or integrity of user entries is provided. Wrong data entered would probably result in the famous "Redo from start" error message or "Division by zero" or "Overflow" or similar message, and the program could abort. After the limits are checked the user is prompted again. Answer Y if the limits are now correct. The next prompt would be: "Save the data (N)?" Which actually means to save the limits just entered. The default answer here is N, which means not to save the limits (into a file for later retrieval). When the ENTER key is pressed (or any other key apart from Y) then the program will continue with graphics on the graphics screen. When the Y key (mind the case) is pressed the the user is prompted to supply a filename where the limits data would be stored. The user has now two choices; either to type name (no check on legality or file existence) or just press the ENTER key to use the default file (PLOT0?.SET - the question mark stands for numerals 1 to 4 which are the actual plotting choices from the Main Menu). The next step after this routine is the actual plot on the graphics screen. 3.3.4. Graphics Screen Plot. --------------------- The drawing on the graphics screen is optional, that means the user is prompted before each drawing routine. The first drawing routine is to draw the experi- mental points: "Draw points (Y)?" The default answer is Y (or just press the ENTER key). The experimental points will be drawn on the graphics screen as small crosses. When the user does not wish the points to be drawn then the answer must be N (capital case). The next one is the point connection routine. Depending on the original plot- ting choice (from the Main Menu) there would be either curve or line drawn through the points "Connect these points by line (Y)?" The next one is the legend routine. Note that only x axis legend is allowed and it serves also as the title of the graph. "Legend (Y/N)?" (max. 80 chars.) TEST PLOT FOR "EXPERIMENTAL DATA POINTS" Here we have three choices; type Y (mind the case) to enter the legend (in which case the old legend, if any, will be written over), type N (again, mind the case, in which case the old legend, if any, will be erased), and press ENTER (in which case the old legend, if any, will be left unchanged). The next routine will draw axis: "Draw axis (Y)?" And the last routine will draw axis ticks and the x axis legend (which is also the title of the graph): "Draw ticks and labels (Y)?" Finally, the user will have a choice of repeating the graphics screen routines or to exit and plot on graphics plotter: "Type R to repeat the routine, E to exit:" This concludes screen graphics. The following is related to plotter. 3.4. Graphics plotter routines. -------------------------- The first prompt that appears is: "Continue with the plotter routines? (Y)" Pressing N key (mind the case) will end the program; that means that all the files created so far with the default filenames are left intact. To continue the program (to plot on the plotter) will require to type PLOT02 and the program will resume with the plotter routines, or, if the user wishes to start again with the graphics screen routines, then PLOT01 should be typed and the program will do the screen graphics again. Any other key will cause continuation of the program. The next prompt will ask for the type of the plotter: "Plotter is HP (Y/N)?" The user has to press Y or N key to continue (again, mind the case) with the program. When HP is chosen then the baud rate is changed from 9600 (default) to 2400 and the plotting area is changed to suit Hewlett-Packard plotter, where the plotting area (in absolute plotter units) is 11420x8140, whereas for the other choice, the FACIT plotter, the baud rate is 9600 and the area is 10880x7640 (plotting area: routine 6010, baud rate and communication port setup: subroutine 1000, output to the port: subroutine 3200, all in PLOT02.BAS). Now will follow routines for the setup of the chosen plotter. Routines are in similar order as in the graphics screen setup. The first will prompt the user to choose either which data set to use, or, if spline functions or regression analysis was chosen in the Main Menu, then which function or which model to take. "There are 2 sets of data. Do data set no.:" Make your choice and the following screen will appear: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================ Type K to use keyboard, D data-file for plotter set-up: D \__________________________________________________________________________/ Here wee answer D (mind the case) because we have already saved the setup limits (in the default file PLOT01.SET). We will be prompted for the filename, where simply by pressing the ENTER key the default file is read. Otherwise the user has to supply his file. No check on file existence or on the integrity of the file contents is done. The next screen will display the limits of the plotting areas: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= All the text (incl. labels) is outside the drawing area indicated The total graphics area is 285.5 x 203.5mm Suggested plotting areas are as follows: ------------------------------------------------------ | x-axis (as on Hewlett-Packard) | default margins | horizontal | vertical | vertical* | set ------------------------------------------------------ left 55.50 40.00 31.25 55.5 right 40.00 55.50 134.375 40 bottom 41.00 41.00 37.50 41 top 20.00 20.00 40.625 20 default plotting area is 176.5 x 130 note: all values in mm *) suitable for daisy-wheel printer (text) and plot together OK (Y/N)? Y \__________________________________________________________________________/ The screen is self-explanatory and if some changes are needed the press the N key and change all that necessary. The plotting area will be re-calculated and displayed again. Pressing Y key will cause the display of the plotting limits: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================ Axis intersect at X = 0 Y = 0 X(MIN) = 0 X(MAX) = 10 Y(MIN) = 0 Y(MAX) = 100 -------------------------------------------------------------- X-axis divisions = 10 Y-axis divisions = 10 -------------------------------------------------------------- F(MIN) = 0 F(MAX) = 0 -------------------------------------------------------------- X-axis tick (% above) = .5 (% below) = .5 Y-axis tick (% right) = .5 (% left) = .5 OK (Y/N)? \__________________________________________________________________________/ The lengths of the axis ticks are expressed here as percentage of the correspon- ding axis span. So to draw a grid, all that is necessary is to extend the axis tick to 100% above the x axis and 100 left of the y axis. It does not really matter whether the graph is the "Portrait" or "Landscape". The position of the x axis is viewed as being always horizontal, that is, when using the "Portrait" we turn the drawing paper the way that the x axis will be still horizontal but parallel with the shorter side of the drawing paper. It should be noted that the ticks are drawn "twice", that is, the pen (when down) moves to the ticks up- per position then to the lower position before returning to the axis (then up). It can be called "double strike" on a printer. Does not really matter much be- cause everything else can be drawn as many times as the user likes it. The next screen is for axis labels: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Multiplication factor, x-axis is 1 y-axis is 1 x-axis is (horiz.=0, vert.=1) 0 Label char. size width (% of x-span) is .55 height (% of y-span) is 1.15 OK (Y)? \__________________________________________________________________________/ The multiplication factors are valid only for labelling the axis and have no effect on the actual drawing of points and functions. Thus, if the labels in the original user units would occupy too many character spaces to fit the divi- sions on the axis, then the plot is drawn as it would be but the labels would be 10 times lower if the multiplication factor is .1, and so on. The relation between the label value and the real value is: (label value) = (real value) * (multiplication factor) Other people may take a different view. The direction in which all the labels are drawn is the direction of the x axis. The default "mode" is x axis horizontal (so called "landscape"), which means that x axis is parallel to the longer side of the drawing paper. The default size of the characters approximately corresponds to PICA 10 on a printer. The next screen sets up the legends: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Legend for x-axis is Legend for y-axis is Legend char. size width (% of x-span) is .55 height (% of y-span) is 1.15 OK (Y)? \__________________________________________________________________________/ This routine may look somehow confusing. The first display shows that there are no legends for the axis, which is all right because the legends were not entered yet. By answering N (mind the case), the display will change to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Legend for x-axis is [OK (Y)]? Legend for y-axis is Legend char. size width (% of x-span) is .55 height (% of y-span) is 1.15 OK (Y)? N \__________________________________________________________________________/ The prompt has moved at the "Legend for x-axis is" prompt. Now since there is still no x axis legend the user has to answer N (again, mind the case) to be prompted down the screen to type the x axis legend: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Legend for x-axis is [OK (Y)]? N Legend for y-axis is Legend char. size width (% of x-span) is .55 height (% of y-span) is 1.15 -> \__________________________________________________________________________/ The prompt is an arrow, "->", where the user has to type the x axis legend. The limit is about 80 characters and will appear centered (with respect to the x axis length when drawn. After the legend is typed (assuming the user has typed ABSCISSA) and the ENTER key is pressed the screen will change to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Legend for x-axis is [OK (Y)]? ABSCISSA Legend for y-axis is Legend char. size width (% of x-span) is .55 height (% of y-span) is 1.15 ->ABSCISSA \__________________________________________________________________________/ And the user is prompted again whether the legend is all right. To change the legend again the user has to press N and the routine will be repeated. Pressing Y or ENTER key the prompt will shift after the prompt "Legend for y-axis is". The same procedure as for the x axis legend will follow. The character size is approximately that of PICA 10 on a printer. The legends are drawn parallel with their corresponding axis. Before leaving this routine the screen will look similar to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Legend for x-axis is ABSCISSA Legend for y-axis is ORDINATE Legend char. size width (% of x-span) is .55 height (% of y-span) is 1.15 OK (Y)? \__________________________________________________________________________/ Pressing N the routine will start all over again. Typing Y or pressing ENTER key the routine for graph title will start: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Title of the graph is Title char. size width (% of x-span) is .55 height (% of y-span) is 1.15 Title justification is (left=0, centered=1) 0 OK (Y)? \__________________________________________________________________________/ The procedure for the title is the same as for the legends. Here the user has option to have the graph title either centered or left justified (with respect to the x axis. Assuming that the user typed "TEST PLOT" the final screen of this routine would look similar to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Title of the graph is TEST PLOT Title char. size width (% of x-span) is .55 height (% of y-span) is 1.15 Title justification is (left=0, centered=1) 1 OK (Y)? \__________________________________________________________________________/ The next routine is to choose the symbol to be drawn for experimental points. The screen should look similar to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================ When drawing experimental points, include rel. error (N)? Symbol for the points: X Char. size, width (% x-span): .55 Char. size, height (% x-span): 1.15 OK (Y)? \__________________________________________________________________________/ The first question is whether to include relative errors when drawing the sym- bol. Default answer is N, but if the errors are to be included then the symbol for the experimental points will be a rectangle having the sizes of its sides doubles of the relative x and y errors. There are two options of getting the experimental error values. If there is an average relative error for x values and an average relative error for y values, then these two values have to be typed-in. However, if each x and each y value has its error then these are in- puted from a data file nominated by the user. The structure of that file is the same as the experimental data file; random access, binary, record length is 4 bytes storage (real numbers), max 640 records. If the user chooses the default, N, then experimental errors are ignored and the user will be prompted to specify the symbol for the experimental points. The symbol must be taken from plotter standard character set. The geometric center of that symbol is the experimental point. After making his selection the user is then prompted to specify the line type for the line or curve connecting the points or going through the set. /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================ Line types that can be used to plot functions: Solid line (type 0) Dotted line (type 1) Dashed line (type 2) Dotted/dashed line (type 3) Line type? \__________________________________________________________________________/ The screen is self-explanatory. When the user chooses the line type other than 0 then he will be prompted to specify the pattern length. This is actually the last screen for the plotter setup and plotting enhance- ments. The next step is to choose to save the setup data into a file, repeat the setup routine, or to plot: "Type R to repeat the routine, S to save the setup data, P to plot:" When the setup data are to be saved, then the user is prompted to specify the name of the file to hold the data. If the ENTER key is pressed after the prompt then the default name, PLOT0?.SET (the question mark stands for numerals 1 to 4 specifying the number of the plotting option selected at the Main Menu), is sup- plied and the setup data are written into it. If the user supplies the name no check for file existence or legality of the name is provided. After the file is written to, the last prompt will appear again: "Type R to repeat the routine, S to save the setup data, P to plot:" This time we will choose to plot. The screen will look similar to this: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ Plot experimental points. ============================================================================= Output to P)lotter or D)ata file? \__________________________________________________________________________/ The user is prompted to specify the direction of the output of this program. There is a choice to plot on the plotter or to store the command lines, which would be normally send to a plotter, in a data file. The structure of the data file is sequential, ascii, delimited by CR/LF sequence, all in accordance with the Microsoft Basic sequential file format. The following prompts will appear whether the output is directed to the plotter or not: "Change plotting paper, press ENTER when ready!" If the output is directed to the plotter then after pressing the ENTER key, the serial port is initialized first before the command strings to setup the plotter to x-on/x-off handshake is send. If the output goes to a file then no initialization of the serial port takes place. Before each routine sends command lines to the plotter (or to the file) the user is prompted: "Draw axis (Y)?" "Label axis (Y)?" "Plot legend (Y)?" "Plot title (Y)?" "Plot points (Y)?" "Connect points by line (Y)?" or "Plot function (Y)?" The default is to utilize that particular routine and to draw, but, if for any reason the user wishes to skip any of the routines, he has to press N (mind the case). After the user presses ENTER, which means to go on with the plotting, he is prompted to make selection of the pen color. The choices are those of the FACIT plotter and are, more or less, arbitrary. If the user wishes he can change the thickness of the pen instead. The following will appear on the screen: Color pens available on FACIT plotter are as follows: Black (type 1 or RETURN) Red (type 2) Green (type 3) Blue (type 4) Orange (type 5) Brown (type 6) Color no.: When all is finished, the last screen will appear: - to repeat the same plot, type A, - to plot next set of data, type S, - to change the plotter, type P, - to enter new data, type D, - to exit this program, type X, Your choice? The first option, repeat the same plot, will not appear when plotting into a data file. If the A (mind the case) is chosen then the following prompt will appear: "Change plotting paper, press ENTER when ready!" and, if different colors for pens were chosen, once or more times: "Change pen, then press ENTER to continue!" before returning back to the last screen. Selecting S will cause the program to got to the beginning of the setup menu where the selection of data sets or functions or regression models takes place. Selecting P will cause the program to go to the very beginning of the plotter routines where the selection of the plotter (as well as the baud rate) takes place. Selecting D will cause the program to to the very beginning of the whole pro- gram, the Main Menu (PLOT.COM chaining). The flag file, PLOT.FLG is cleared and PLOT.$$$ is set to all zeros. All other files are left untouched, but will be written over whenever the program course will require. Selecting X will cause the end of the program. Control goes to the operating system. All the files are left untouched for the user's disposal. June 1991, Henry Brancik, henryb@usage.csd.unsw.oz.AU (UNIX machine) (Sch. Fiber Sci. Technl., Univ. N. S. W., Australia)