Begin by starting the GnuPLOT executable:
Our first plot is the simplest case of a horizontal line:
This is, of course, a horizontal line passing through the point (x, C). If we assign a value to C we can plot by doing:
gnuplot> plot 5
To make this a more interesting plot (as these things go), we can plug in different values into the equation of a line:
Linear equations form the basis for later analysis. Though the equation of a line is straightforward, 1 a thorough understanding of its twists and turns is necessary to grasp the calculus and complex analysis. In this next example we will use GnuPLOT to graph variations on the line. The power of the graphing tool becomes apparent when one aspect of a function is changed and the resultant graph is updated.
For the next example we will adjust how the graph is displayed by
turning on the background grid. We'll graph the function
by typing the following commands:
gnuplot> set grid gnuplot> plot 2*x + 1
Figure 1 shows the resulting plot. You may notice that the graph covers a large range and domain. There are many instances when it would be more enlightening to concentrate on a particular section of the graph. For example, in the graph of a quadratic equation we would generally be concerned about the zeroes or vertex rather than the overall plot. To limit GnuPLOT to a range or domain use the following:
gnuplot> plot [-5:5] [-6:6] 2*x + 1
In this case we have limited the section of plot to 5 units above and below the X axis and 6 units to the left and right of the Y axis. Of course, were we to zoom in to very small sections of the line or to zoom out to very large sections, the line would still look very much the same.
Thus, our next example is a standard quadratic of the form:
We'll arbitrarily assign values and plot the equation
by typing:
gnuplot> plot [-3:2] [1:5] 2*x**2 + 3*x + 4
Note that we explicitly show multiplication by using the asterisk. We use
the double-asterisk to specify exponentation. Finally, GnuPLOT takes care
of the order of operations, as it should, and explicit parentheses are
not needed around the
term.
We are not limited to graphs within the XY plane as GnuPLOT can easily graph
in three dimensions using the splot command. For example, to plot
the somewhat visually interesting graph of
we enter
the following:
gnuplot> set grid gnuplot> set isosamples 40 gnuplot> set hidden gnuplot> splot [-5:5] [-5:5] sin(x) * cos(y)
Figure 3 shows the graph of this function. The lines of interest are the set isosamples and set hidden commands. The higher isosamples will increase the apparent smoothness of the plot. The hidden command removes hidden lines from the plot. Hidden lines are portions of the graph that are occluded behind the graph in the foreground.