PREV UP NEXT GNU Emacs Calc 2.02 Manual

14.2: Three-Dimensional Graphics

The g F (calc-graph-fast-3d) command makes a three-dimensional graph. It works only if you have GNUPLOT 3.0 or later; with GNUPLOT 2.0, you will see a GNUPLOT error message if you try this command.

The g F command takes three values from the stack, called ``x'', ``y'', and ``z'', respectively. As was the case for 2D graphs, there are several options for these values.

In the first case, ``x'' and ``y'' are each vectors (not necessarily of the same length); either or both may instead be interval forms. The ``z'' value must be a matrix with the same number of rows as elements in ``x'', and the same number of columns as elements in ``y''. The result is a surface plot where z_ij is the height of the point at coordinate (x_i, y_j) on the surface. The 3D graph will be displayed from a certain default viewpoint; you can change this viewpoint by adding a `set view' to the `*Gnuplot Commands*' buffer as described later. See the GNUPLOT 3.0 documentation for a description of the `set view' command.

Each point in the matrix will be displayed as a dot in the graph, and these points will be connected by a grid of lines (isolines).

In the second case, ``x'', ``y'', and ``z'' are all vectors of equal length. The resulting graph displays a 3D line instead of a surface, where the coordinates of points along the line are successive triplets of values from the input vectors.

In the third case, ``x'' and ``y'' are vectors or interval forms, and ``z'' is any formula involving two variables (not counting variables with assigned values). These variables are sorted into alphabetical order; the first takes on values from ``x'' and the second takes on values from ``y'' to form a matrix of results that are graphed as a 3D surface.

If the ``z'' formula evaluates to a call to the fictitious function `xyz(x, y, z)', then the result is a ``parametric surface.'' In this case, the axes of the graph are taken from the x and y values in these calls, and the ``x'' and ``y'' values from the input vectors or intervals are used only to specify the range of inputs to the formula. For example, plotting `[0..360], [0..180], xyz(sin(x)*sin(y), cos(x)*sin(y), cos(y))' will draw a sphere. (Since the default resolution for 3D plots is 5 steps in each of ``x'' and ``y'', this will draw a very crude sphere. You could use the g N command, described below, to increase this resolution, or specify the ``x'' and ``y'' values as vectors with more than 5 elements.

It is also possible to have a function in a regular g f plot evaluate to an xyz call. Since g f plots a line, not a surface, the result will be a 3D parametric line. For example, `[[0..720], xyz(sin(x), cos(x), x)]' will plot two turns of a helix (a three-dimensional spiral).

As for g f, each of ``x'', ``y'', and ``z'' may instead be variables containing the relevant data.