Next: Graphics Options, Previous: Three Dimensional Graphics, Up: Graphics [Contents][Index]

The `g f` command is really shorthand for the following commands:
`C-u g d g a g p`. Likewise, `g F` is shorthand for
`C-u g d g A g p`. You can gain more control over your graph
by using these commands directly.

The `g a` (`calc-graph-add`

) command adds the “curve”
represented by the two values on the top of the stack to the current
graph. You can have any number of curves in the same graph. When
you give the `g p` command, all the curves will be drawn superimposed
on the same axes.

The `g a` command (and many others that affect the current graph)
will cause a special buffer, `*Gnuplot Commands*`, to be displayed
in another window. This buffer is a template of the commands that will
be sent to GNUPLOT when it is time to draw the graph. The first
`g a` command adds a `plot`

command to this buffer. Succeeding
`g a` commands add extra curves onto that `plot`

command.
Other graph-related commands put other GNUPLOT commands into this
buffer. In normal usage you never need to work with this buffer
directly, but you can if you wish. The only constraint is that there
must be only one `plot`

command, and it must be the last command
in the buffer. If you want to save and later restore a complete graph
configuration, you can use regular Emacs commands to save and restore
the contents of the `*Gnuplot Commands*` buffer.

If the values on the stack are not variable names, `g a` will invent
variable names for them (of the form ‘`PlotData n`’) and store
the values in those variables. The “x” and “y” variables are what
go into the

`plot`

command in the template. If you add a curve
that uses a certain variable and then later change that variable, you
can replot the graph without having to delete and re-add the curve.
That’s because the variable name, not the vector, interval or formula
itself, is what was added by A numeric prefix argument on `g a` or `g f` changes the way
stack entries are interpreted as curves. With a positive prefix
argument ‘`n`’, the top ‘`n`’ stack entries are “y” values
for ‘`n`’ different curves which share a common “x” value in
the ‘`n+1`’st stack entry. (Thus `g a` with no prefix
argument is equivalent to `C-u 1 g a`.)

A prefix of zero or plain `C-u` means to take two stack entries,
“x” and “y” as usual, but to interpret “y” as a vector of
“y” values for several curves that share a common “x”.

A negative prefix argument tells Calc to read ‘`n`’ vectors from
the stack; each vector ‘`[x, y]`’ describes an independent curve.
This is the only form of `g a` that creates several curves at once
that don’t have common “x” values. (Of course, the range of “x”
values covered by all the curves ought to be roughly the same if
they are to look nice on the same graph.)

For example, to plot
‘`sin(n x)`’
for integers ‘`n`’
from 1 to 5, you could use `v x` to create a vector of integers
(‘`n`’), then `V M '` or `V M $` to map ‘`sin(n x)`’
across this vector. The resulting vector of formulas is suitable
for use as the “y” argument to a `C-u g a` or `C-u g f`
command.

The `g A` (`calc-graph-add-3d`

) command adds a 3D curve
to the graph. It is not valid to intermix 2D and 3D curves in a
single graph. This command takes three arguments, “x”, “y”,
and “z”, from the stack. With a positive prefix ‘`n`’, it
takes ‘`n+2`’ arguments (common “x” and “y”, plus ‘`n`’
separate “z”s). With a zero prefix, it takes three stack entries
but the “z” entry is a vector of curve values. With a negative
prefix ‘`-n`’, it takes ‘`n`’ vectors of the form ‘`[x, y, z]`’.
The `g A` command works by adding a `splot`

(surface-plot)
command to the `*Gnuplot Commands*` buffer.

(Although `g a` adds a 2D `plot`

command to the
`*Gnuplot Commands*` buffer, Calc changes this to `splot`

before sending it to GNUPLOT if it notices that the data points are
evaluating to `xyz`

calls. It will not work to mix 2D and 3D
`g a` curves in a single graph, although Calc does not currently
check for this.)

The `g d` (`calc-graph-delete`

) command deletes the most
recently added curve from the graph. It has no effect if there are
no curves in the graph. With a numeric prefix argument of any kind,
it deletes all of the curves from the graph.

The `g H` (`calc-graph-hide`

) command “hides” or “unhides”
the most recently added curve. A hidden curve will not appear in
the actual plot, but information about it such as its name and line and
point styles will be retained.

The `g j` (`calc-graph-juggle`

) command moves the curve
at the end of the list (the “most recently added curve”) to the
front of the list. The next-most-recent curve is thus exposed for
`g d` or similar commands to use. With `g j` you can work
with any curve in the graph even though curve-related commands only
affect the last curve in the list.

The `g p` (`calc-graph-plot`

) command uses GNUPLOT to draw
the graph described in the `*Gnuplot Commands*` buffer. Any
GNUPLOT parameters which are not defined by commands in this buffer
are reset to their default values. The variables named in the `plot`

command are written to a temporary data file and the variable names
are then replaced by the file name in the template. The resulting
plotting commands are fed to the GNUPLOT program. See the documentation
for the GNUPLOT program for more specific information. All temporary
files are removed when Emacs or GNUPLOT exits.

If you give a formula for “y”, Calc will remember all the values that
it calculates for the formula so that later plots can reuse these values.
Calc throws out these saved values when you change any circumstances
that may affect the data, such as switching from Degrees to Radians
mode, or changing the value of a parameter in the formula. You can
force Calc to recompute the data from scratch by giving a negative
numeric prefix argument to `g p`.

Calc uses a fairly rough step size when graphing formulas over intervals.
This is to ensure quick response. You can “refine” a plot by giving
a positive numeric prefix argument to `g p`. Calc goes through
the data points it has computed and saved from previous plots of the
function, and computes and inserts a new data point midway between
each of the existing points. You can refine a plot any number of times,
but beware that the amount of calculation involved doubles each time.

Calc does not remember computed values for 3D graphs. This means the
numerix prefix argument, if any, to `g p` is effectively ignored if
the current graph is three-dimensional.

The `g P` (`calc-graph-print`

) command is like `g p`,
except that it sends the output to a printer instead of to the
screen. More precisely, `g p` looks for ‘`set terminal`’
or ‘`set output`’ commands in the `*Gnuplot Commands*` buffer;
lacking these it uses the default settings. However, `g P`
ignores ‘`set terminal`’ and ‘`set output`’ commands and
uses a different set of default values. All of these values are
controlled by the `g D` and `g O` commands discussed below.
Provided everything is set up properly, `g p` will plot to
the screen unless you have specified otherwise and `g P` will
always plot to the printer.

Next: Graphics Options, Previous: Three Dimensional Graphics, Up: Graphics [Contents][Index]