Function: math[gridplot] - plots graphs on 'graph paper'
Calling Sequence:
gridplot(f, h, v, ...);
gridplot(f, x=a .. b, y=c .. d, plotoptions and/or gridplotoptions);
gridplot(f, x, y=c .. d, plotoptions and/or gridplotoptions);
Parameters:
f
- function(s) to be plotted
h
- horizontal range
v
- vertical range
x
- indeterminate in f
y
- the name 'y'
a, b, c, d
- numerics
plotoptions
- (optional) various
plot options
gridplotoptions
- (optional) various
gridplot options
Description:
This function works like the plot command for cartesian and parametric 2D-plots, but also adds a cartesian grid ('graph paper').
The syntax for gridplot is the same as for plot, but with parametric plots, the horizontal and vertical plot ranges x=a .. b and y=c .. d or simply c .. d must be given. You may pass any valid plotoptions to gridplot.
In the second form, a cartesian plot is generated with the x-range a .. b, and the optional y-range c .. d. Various plot and gridplot options may be passed, as well.
The third form works like the second form, but the default plot x-range -10 .. 10 is used.
If the vertical range is absent, gridplot determines the absolute minimum and maximum values of all the functions given. If there are discontinuities (i.e. +/-infinity) the vertical range is set -100 .. 100. So in these cases you may choose other values by passing a vertical plot range and/or setting the units or step options (see below)according to your needs.
The return is a PLOT structure. The axis labels are determined from the input, so if discont=true and the vertical range is given as a plot range (including a name on the left-hand side of the equation), the `y` label IS plotted. Thus the minor 'bug' in `plot/discontplot` does not have an effect on the plot.
Internally, gridplot uses the plot, `math/cartgridR3` or `math/pointgridR3`, and plots[display] functions.
With the option 'grid1'=<list>, the user can define any valid plot options for the first grid by putting them in a list; in this case options gridcolor, gridlinestyle, and gridthickness will be ignored.
With the option grid2 it is possible to generate and display a second grid which preferably has different thickness, step, etc. settings. If only the name 'grid2' is passed then the second grid has step size 2 and thickness 2. If you pass an equation 'grid2' = <list>, where <list> is a list with one or more plot options and/or the step option, then those values are used to process the second grid.
With the option 'points'=<list>, the user can define any valid plot options for the points by putting them in a list. If only the name 'points' is given, then the defaults are symbol=POINT, color=black.
Technically, both with the grid1 and grid2 option, all the options included in <list> are passed to math/cartgridR3 along with the plot ranges.
This function is part of the math package, and so can be used only after performing the command with(math) or with(math, gridplot).
Examples:
> with(math):
> f := x -> (1/2*x^3-3/2*x+1)/(x^2+3*x+2):
> a := un(asym(f(x))): # see math[asym] and math[un]
>
gridplot({f(x), a(x)}, x=-8 .. 7, y=-7 .. 7, # cartesian plot
discont=true,
step=[1, 1],
units=[2, 2],
gridcolor=lightgrey80,
color=[navy, red],
axesfont=[HELVETICA, 10],
titlefont=[HELVETICA, BOLD, 12],
title=`Die Funktion f und ihre Asymptote a`);
> gridplot([sin(t), cos(t), t=-Pi .. Pi], x=-2 .. 2, -2 .. 2); # parametric plot
> gridplot(x, x=-4 .. 4, y=-4 .. 4, grid2);
>
gridplot((x^3-x^2+x)/(x-2)^3, x=-8 .. 8, y=-8 .. 8,
discont=true,
color=blue,
grid1=[color=black, step=2],
grid2=[step=4, color=red, thickness=2]);
>
gridplot({f(x), a(x)}, x=-8 .. 7, y=-7 .. 7,
points=[color=darkcyan],
discont=true,
step=[1, 1],
units=[2, 2],
color=[navy, red],
axesfont=[HELVETICA, 10],
titlefont=[HELVETICA, BOLD, 12],
title=`Die Funktion f und ihre Asymptote a`);
See Also:
plot , math/cartgridR3 , math/pointgridR3 .
Credits:
Idea for this procedure:
Ulrich Rauscher, Backnang, Federal Republic of Germany
Idea for the second grid:
Armin Geisse, Muenchsmuenster, Federal Republic of Germany
Version History:
Version 1.00 - April 11, 1997
Version 1.01 - April 13, 1997
Version 1.02 - April 17, 1997
Version 1.03 - April 25, 1997
Version 1.04 - January 05, 1998
Version 2.0 - January 07, 1998
Version 2.1 - February 07, 1998
Version 2.2 - February 23, 1998
Version 2.3 - March 14, 1998
Version 2.4 - April 19, 2000