### XYPLOT [LOG] xVector yVector {yVector}

 The XYPLOT command prints its input vectors as an x-y text plot in the Output Window. The XYPLOT command can be used to display a scatter chart, or to graph functions. One independent variable vector (xVector) is required, and at least one dependent variable vector (yVector) is required. Currently, the maximum numbers of yVectors allowed is 35. If more than one yVector is supplied, each will be plotted with a different identifying character, called a "marker" here, to distinguish it from the others. The markers for the first three yVectors are "+", "o", and "*". All input vectors must be the same length. In other words, there must be an element in each yVector for each element in the xVector. If elements of several yVectors map to the same position on the graph, only the marker of the last yVector in the command will be printed in the graph. That's because only one marker can be printed in one character space, so the last one "overwrites" any earlier ones. The examples at right show uses of the command with its output. Note that the x-axis is printed down the page while the y-axis prints across the page. There are 51 characters in the y direction and 51 rows in the x direction. The "Legend" identifies which marker goes with which yVector. The "Major Interval" gives the amount that a five character length represents in the y direction. In other words, the Major Interval is the amount of y between two colons (:....:). The Minor Interval is the amount represented by one character space in the y direction. Since the smallest resolution that can be represented in a plot such as this is the size of one character, each row represents a range of x values and each column represents a range of y values. The number printed for each x row is the value associated with the low end of that row's range. The upper end of the range is infinitesimally below the value printed for the next row down. For example, arbitrarily choosing x=9 in the first graph at right, the low end of the range for that row is 9.0. The upper end of the range is just under 10. In other words, the range of values represented by the x=9 row is 9 <= x < 10. The same reasoning applies to the range of values related to a y column, although the values for all the y columns are not printed. If any element of any xVector is NaN (Not a Number), the corresponding element will be ignored in all the yVectors. If a NaN occurs in any yVector, only the point represented by that element in that yVector will be ignored. If the keyword log is present, the y-axis will be drawn with a logarithmic scale. The log keyword, if present, must immediately follow the XYPLOT command name. The "Major Interval" and "Minor Interval" information will not be printed because it is only relevant to linear charts. The grid lines representing powers of 10 will be indicated on the chart with colons. Note that y values that are zero or negative are not allowed on a log chart and will cause an error message during the program's execution. See also the XYGRAPH and SCATTERGRAPH commands. Here's a program that will compute three binomial distributions and plot them on the same graph: ```BINOMIALPROB 50 0.5 fiftyFiftyProbability BINOMIALPROB 50 0.8 eightyPercentProbability BINOMIALPROB 50 0.9 ninetyPercentProbability COPY 0,50 x XYPLOT x fiftyFiftyProbability eightyPercentProbability ninetyPercentProbability``` The above program produces the following output: ``` Legend: + = fiftyFiftyProbability o = eightyPercentProbability * = ninetyPercentProbability Major Interval: 0.02 Minor Interval: 0.0040 0.0E00 0.1 0.2 0.0E00 *----:----:----:----:----:----:----:----:----:----: 1 *....:....:....:....:....:....:....:....:....:....: 2 *....:....:....:....:....:....:....:....:....:....: 3 *....:....:....:....:....:....:....:....:....:....: 4 *....:....:....:....:....:....:....:....:....:....: 5 *....:....:....:....:....:....:....:....:....:....: 6 *....:....:....:....:....:....:....:....:....:....: 7 *....:....:....:....:....:....:....:....:....:....: 8 *....:....:....:....:....:....:....:....:....:....: 9 *....:....:....:....:....:....:....:....:....:....: 10 *....:....:....:....:....:....:....:....:....:....: 11 *....:....:....:....:....:....:....:....:....:....: 12 *....:....:....:....:....:....:....:....:....:....: 13 *....:....:....:....:....:....:....:....:....:....: 14 *....:....:....:....:....:....:....:....:....:....: 15 *....:....:....:....:....:....:....:....:....:....: 16 *+...:....:....:....:....:....:....:....:....:....: 17 *.+..:....:....:....:....:....:....:....:....:....: 18 *...+:....:....:....:....:....:....:....:....:....: 19 *....:+...:....:....:....:....:....:....:....:....: 20 *....:....+....:....:....:....:....:....:....:....: 21 *....:....:...+:....:....:....:....:....:....:....: 22 *....:....:....:...+:....:....:....:....:....:....: 23 *....:....:....:....:..+.:....:....:....:....:....: 24 *....:....:....:....:....:+...:....:....:....:....: 25 *....:....:....:....:....:..+.:....:....:....:....: 26 *....:....:....:....:....:+...:....:....:....:....: 27 *....:....:....:....:..+.:....:....:....:....:....: 28 *....:....:....:...+:....:....:....:....:....:....: 29 *....:....:...+:....:....:....:....:....:....:....: 30 *....:....+....:....:....:....:....:....:....:....: 31 *....:+...:....:....:....:....:....:....:....:....: 32 *...+:....:....:....:....:....:....:....:....:....: 33 *.o..:....:....:....:....:....:....:....:....:....: 34 *+..o:....:....:....:....:....:....:....:....:....: 35 *....:.o..:....:....:....:....:....:....:....:....: 36 *....:....:.o..:....:....:....:....:....:....:....: 37 *....:....:....:..o.:....:....:....:....:....:....: 38 *....:....:....:....:....o....:....:....:....:....: 39 +*...:....:....:....:....:....:o...:....:....:....: 40 +..*.:....:....:....:....:....:...o:....:....:....: 41 +....:..*.:....:....:....:....:...o:....:....:....: 42 +....:....:....:*...:....:...o:....:....:....:....: 43 +....:....:....:....:o...:*...:....:....:....:....: 44 +....:....:..o.:....:....:....:....:..*.:....:....: 45 +....:.o..:....:....:....:....:....:....:....:*...: 46 +..o.:....:....:....:....:....:....:....:....*....: 47 +o...:....:....:....:....:....:...*:....:....:....: 48 o....:....:....:...*:....:....:....:....:....:....: 49 o....:.*..:....:....:....:....:....:....:....:....: 50 o*...:....:....:....:....:....:....:....:....:....: ``` This next program plots the sine function from -pi to + pi. First, it calculates the value of two PI divided by 50. Then it creates a vector, x, containing 51 x values from -pi to + pi. Next, it computes the sines of those x values and puts them in the vector y. Finally, it plots y versus x. ```MULTIPLY 3.14159 2 0.02 twoPiOverFifty MULTIPLY -25,25 twoPiOverFifty x SIN x sinX XYPLOT x sinX``` As a point of information, the first two lines could be compressed into one as shown here. ```MULTIPLY 3.14159 2 0.02 -25,25 x SIN x sinX XYPLOT x sinX ``` Here's the output (of either program): ``` Legend: + = sinX Major Interval: 0.2 Minor Interval: 0.04 -1 0.0E00 1 -3.14159 :....:....:....:....:...+|....:....:....:....:....: -3.015926 :....:....:....:....:+...|....:....:....:....:....: -2.890263 :....:....:....:..+.:....|....:....:....:....:....: -2.764599 :....:....:....+....:....|....:....:....:....:....: -2.638936 :....:....:.+..:....:....|....:....:....:....:....: -2.513272 :....:....+....:....:....|....:....:....:....:....: -2.387608 :....:.+..:....:....:....|....:....:....:....:....: -2.261945 :....+....:....:....:....|....:....:....:....:....: -2.136281 :..+.:....:....:....:....|....:....:....:....:....: -2.010618 :.+..:....:....:....:....|....:....:....:....:....: -1.884954 :+...:....:....:....:....|....:....:....:....:....: -1.75929 +....:....:....:....:....|....:....:....:....:....: -1.633627 +....:....:....:....:....|....:....:....:....:....: -1.507963 +....:....:....:....:....|....:....:....:....:....: -1.3823 +....:....:....:....:....|....:....:....:....:....: -1.256636 :+...:....:....:....:....|....:....:....:....:....: -1.130972 :.+..:....:....:....:....|....:....:....:....:....: -1.005309 :..+.:....:....:....:....|....:....:....:....:....: -0.879645 :....+....:....:....:....|....:....:....:....:....: -0.753982 :....:.+..:....:....:....|....:....:....:....:....: -0.628318 :....:....+....:....:....|....:....:....:....:....: -0.502654 :....:....:.+..:....:....|....:....:....:....:....: -0.376991 :....:....:....+....:....|....:....:....:....:....: -0.251327 :....:....:....:..+.:....|....:....:....:....:....: -0.125664 :....:....:....:....:+...|....:....:....:....:....: 0.0E00 :----:----:----:----:----+----:----:----:----:----: 0.125664 :....:....:....:....:....|..+.:....:....:....:....: 0.251327 :....:....:....:....:....|....:+...:....:....:....: 0.376991 :....:....:....:....:....|....:...+:....:....:....: 0.502654 :....:....:....:....:....|....:....:.+..:....:....: 0.628318 :....:....:....:....:....|....:....:...+:....:....: 0.753982 :....:....:....:....:....|....:....:....:.+..:....: 0.879645 :....:....:....:....:....|....:....:....:...+:....: 1.005309 :....:....:....:....:....|....:....:....:....:+...: 1.130972 :....:....:....:....:....|....:....:....:....:.+..: 1.256636 :....:....:....:....:....|....:....:....:....:..+.: 1.3823 :....:....:....:....:....|....:....:....:....:...+: 1.507963 :....:....:....:....:....|....:....:....:....:...+: 1.633627 :....:....:....:....:....|....:....:....:....:...+: 1.75929 :....:....:....:....:....|....:....:....:....:...+: 1.884954 :....:....:....:....:....|....:....:....:....:..+.: 2.010618 :....:....:....:....:....|....:....:....:....:.+..: 2.136281 :....:....:....:....:....|....:....:....:....:+...: 2.261945 :....:....:....:....:....|....:....:....:...+:....: 2.387608 :....:....:....:....:....|....:....:....:.+..:....: 2.513272 :....:....:....:....:....|....:....:...+:....:....: 2.638936 :....:....:....:....:....|....:....:.+..:....:....: 2.764599 :....:....:....:....:....|....:...+:....:....:....: 2.890263 :....:....:....:....:....|....:+...:....:....:....: 3.015926 :....:....:....:....:....|..+.:....:....:....:....: 3.14159 :....:....:....:....:....+....:....:....:....:....: ``` Here's an example of a log chart. ```COPY 1,51 x SQUARE x xSquared OUTPUT "Plot of Y = square(X)\n\n" XYPLOT log x xSquared ``` The above program produces the following chart. The powers of 10 are indicated by the vertical lines of colons. Here, the major y divisions are 1, 10, 100, 1000, and 10000. ```Plot of Y = square(X) Legend: + = xSquared 1 100 1.0E04 1 +...........:............:............:...........: 2 .......+....:............:............:...........: 3 ...........+:............:............:...........: 4 ............:..+.........:............:...........: 5 ............:....+.......:............:...........: 6 ............:......+.....:............:...........: 7 ............:........+...:............:...........: 8 ............:.........+..:............:...........: 9 ............:..........+.:............:...........: 10 ............:............+............:...........: 11 ............:............:+...........:...........: 12 ............:............:+...........:...........: 13 ............:............:.+..........:...........: 14 ............:............:..+.........:...........: 15 ............:............:...+........:...........: 16 ............:............:....+.......:...........: 17 ............:............:....+.......:...........: 18 ............:............:.....+......:...........: 19 ............:............:.....+......:...........: 20 ............:............:......+.....:...........: 21 ............:............:.......+....:...........: 22 ............:............:.......+....:...........: 23 ............:............:........+...:...........: 24 ............:............:........+...:...........: 25 ............:............:........+...:...........: 26 ............:............:.........+..:...........: 27 ............:............:.........+..:...........: 28 ............:............:..........+.:...........: 29 ............:............:..........+.:...........: 30 ............:............:..........+.:...........: 31 ............:............:...........+:...........: 32 ............:............:...........+:...........: 33 ............:............:...........+:...........: 34 ............:............:............+...........: 35 ............:............:............+...........: 36 ............:............:............+...........: 37 ............:............:............:+..........: 38 ............:............:............:+..........: 39 ............:............:............:+..........: 40 ............:............:............:.+.........: 41 ............:............:............:.+.........: 42 ............:............:............:.+.........: 43 ............:............:............:.+.........: 44 ............:............:............:..+........: 45 ............:............:............:..+........: 46 ............:............:............:..+........: 47 ............:............:............:..+........: 48 ............:............:............:...+.......: 49 ............:............:............:...+.......: 50 ............:............:............:...+.......: 51 ............:............:............:...+.......: ```