2 Plotting
The plot library provides the ability to make basic
plots, fit curves to data, and some useful miscellaneous functions.
2.1 Plotting
The plot and plot3d functions generate plots that can be
viewed in the DrRacket interactions window.
Plots
data in 2-D, where
data is generated by
functions like
points or
lines.
A data value is represented as a procedure that takes a
2d-view% instance and adds plot information to it.
The result is a image-snip% for the plot. If an #:out-file
path or port is provided, the plot is also written as a PNG image to
the given path or port.
Plots
data in 3-D, where
data is generated by a
function like
surface. The arguments
alt and
az set the viewing altitude (in degrees) and the azimuth
(also in degrees), respectively.
A 3-D data value is represented as a procedure that takes a
3d-view% instance and adds plot information to it.
Creates 2-D plot data (to be provided to
plot) given a list
of points specifying locations. The
sym argument determines
the appearance of the points. It can be a symbol, an ASCII character,
or a small integer (between -1 and 127). The following symbols are
known:
'pixel,
'dot,
'plus,
'asterisk,
'circle,
'times,
'square,
'triangle,
'oplus,
'odot,
'diamond,
'5star,
'6star,
'fullsquare,
'bullet,
'full5star,
'circle1,
'circle2,
'circle3,
'circle4,
'circle5,
'circle6,
'circle7,
'circle8,
'leftarrow,
'rightarrow,
'uparrow,
'downarrow.
Creates 2-D plot data to draw a line.
The line is specified in either functional, i.e. y = f(x), or
parametric, i.e. x,y = f(t), mode. If the function is
parametric, the mode argument must be set to
'parametric. The t-min and t-max arguments
set the parameter when in parametric mode.
Creates 2-D plot data for error bars given a list of vectors. Each
vector specifies the center of the error bar (x,y) as the first
two elements and its magnitude as the third.
Creates 2-D plot data to draw a vector-field from a vector-valued
function.
Creates 2-D plot data to draw contour lines, rendering a 3-D function
a 2-D graph cotours (respectively) to represent the value of the
function at that position.
Creates 2-D plot data to draw like
contour, except using
shading instead of contour lines.
Creates 3-D plot data to draw a 3-D surface in a 2-D box, showing only
the top of the surface.
Creates a procedure that calls each data on its argument in
order. Thus, this function can composes multiple plot datas
into a single data.
Returns #t if v is one of the following symbols,
#f otherwise:
'white 'black 'yellow 'green 'aqua 'pink |
'wheat 'grey 'blown 'blue 'violet 'cyan |
'turquoise 'magenta 'salmon 'red |
2.2 Curve Fitting
PLoT uses the standard Non-Linear Least Squares fit algorithm for
curve fitting. The code that implements the algorithm is public
domain, and is used by the gnuplot package.
Attempts to fit a fittable function to the data that is
given. The guess-list should be a set of arguments and
values. The more accurate your initial guesses are, the more likely
the fit is to succeed; if there are no good values for the guesses,
leave them as 1.
The
params field contains an associative list of the
parameters specified in
fit and their values. Note that the
values may not be correct if the fit failed to converge. For a visual
test, use the
function field to get the function with the
parameters in place and plot it along with the original data.
2.3 Miscellaneous Functions
Creates a function that evaluates the numeric derivative of
f. The given h is the divisor used in the
calculation.
Creates a vector-valued function that the numeric gradient of
f.
Creates a vector-values function from two parts.