1. Home
  2. DFUNCTION procedure

DFUNCTION procedure

Plots a function (R.W. Payne).

Options

FUNCTION = expression Function to plot
TITLE = text Title for the plot; default shows the function
COLOUR = text or scalar Colour of the function curve; default 'green'
WINDOW = scalar Which graphics window to use; default 3
ELEVATION = scalar Elevation of the viewpoint for the surface that is plotted when there are two arguments; default 25 (degrees)
AZIMUTH = scalar Rotation about the horizontal plane for the viewpoint of a surface plot; default 225 (degrees)
DISTANCE = scalar Distance of the viewpoint of a surface plot from the centre of the grid on the base plane; default * gives a distance of 100 times the maximum of the x-range and the y-range
ZSCALE = scalar defines the scaling of the z-axis relative to the horizontal (x-y) axes in a surface plot; default 1
SCREEN = string token Whether to clear the screen before plotting (clear, keep, resize); default clea

Parameters

ARGUMENT = scalars Arguments of the function
LOWER = scalars Lower values of the arguments for the plot
UPPER = scalars Upper values of the arguments for the plot
STEP = scalars Steps at which to evaluate the function

Description

DFUNCTION plots a function using high-resolution graphics. The function is specified, as a Genstat expression, using the FUNCTION option.

The arguments of the function (against which the function is to be plotted) are specified by the ARGUMENT parameter. There can be either one or two arguments, and they must each be either a scalar or an undeclared data structure. With one argument a curve is plotted using DGRAPH, while with two arguments a surface is plotted using DSURFACE. The LOWER and UPPER parameters specify the lower and upper values of the arguments to show in the plot. The STEP parameter specifies the step between the values of each ARGUMENT at which the FUNCTION is evaluated in the plot. The default generates 1001 values of a single argument, or 101 values of each argument if there are two.

The TITLE option can supply a title for the plot. If this is not specified, a title is constructed automatically to show the FUNCTION expression. The COLOUR option specifies the colour to use for the function curve or suface. The default is to plot it in green. The WINDOW option specifies which graphics window to use. The default is to use window 3, which should fill the whole frame. The SCREEN option controls whether the screen is cleared before plotting, or whether is is kept, or kept with resizing, from previous plots. By default the screen is cleared.

Options ELEVATION, DISTANCE, AZIMUTH and ZSCALE are relevant only when a surface is plotted (i.e. when there are two arguments), and all operate as in the DSURFACE directive. The ELEVATION, DISTANCE and AZIMUTH options specify the position of the viewpoint, and the ZSCALE option specifies a scaling factor for the z-axis that is used for the function, versus the x- and y-axes that are used for the arguments. See DSURFACE for further details.

Options: FUNCTION, TITLE, COLOUR, WINDOW, ELEVATION, AZIMUTH, DISTANCE, ZSCALE, SCREEN.

Parameters: ARGUMENT, LOWER, UPPER, STEP.

See also

Directives: CALCULATE, EXPRESSION.

Procedure: DTEXT.

Commands for: Graphics.

Example

CAPTION   'DFUNCTION examples'; STYLE=meta
DFUNCTION [FUNCTION=x+x*log(x)] x; LOWER=0.0001; UPPER=1
" Notice that the evaluation at 0 gives a missing value,
  which breaks up the curve into 2 separate parts
  (and generates a warning)."
DFUNCTION [FUNCTION=1/x] x; LOWER=-1; UPPER=1
DFUNCTION [FUNCTION=100*(P2-P1*P1)**2+(1-P1)**2] P1,P2;\
          LOWER=-1.2,0; UPPER=1.2
Updated on March 8, 2019

Was this article helpful?