3.2 First plotsThe core graph-plotting command of Pyxplot is the plot command. The following simple example plots the trigonometric function plot sin(x) ![]() This is one of a large number of standard mathematical functions which are built into Pyxplot; a complete alphabetical list of them can be found in Chapter 12. It is also possible to plot data stored in files. The following would plot data from a file data.dat, taking the plot 'data.dat' Several items can be plotted on the same graph by separating them by commas, as in plot 'data.dat', sin(x), cos(x) and it is possible to define one’s own variables and functions, and then plot them, as in the example a = 0.02 b = -1 c = 5 f(x) = a*(x**3) + b*x + c plot f(x) ![]() Pyxplot supports almost all of the same mathematical operators as the C programming language; a complete list of them can be found in Table 3.1. If you have experience of similar tricks in C, it is quite possible to write the following expressions in Pyxplot (but don’t worry if this is a little over your head): pyxplot> print (a=3)+(b=2) In the final example, the comma operator is used as in C, to return only the value of the final comma-separated expression.
Table 3.1: A list of mathematical operators which Pyxplot recognises, in order of descending precedence. Items separated by horizontal rules are of differing precedence; those not separated by horizontal rules are of equal precedence. The third column indicates whether strings of operators are evaluated from left to right, or from right to left. For example, the expression x**y**z is evaluated as (x**(y**z)). Footnotes
|