On this page:
plot
Plot  Spec
Line  Spec
Point  Spec
Axis  Spec
Transform  Spec
8.14.0.4

10 The plot library🔗ℹ

This library provides a basic wrapper around the line plots provided by Racket’s Plot library.

procedure

plot(title: str?, data: PlotSpec, [x: AxisSpec, y: AxisSpec]): AnyC

The main function in this library: draws a line plot from the given data, and displays it. Run inside DrRacket for best results.

The format of each argument is documented along with their contracts, below. The last two arguments describing axes are both optional.

At its simplest, a plot consisting of a single line can be drawn as follows, with a vector of 2-dimensional points forming the line as the second argument:

plot("line", [[1,1], [2,2], [3,3]])

Axes may optionally be labeled:

plot("line", [[1,1], [2,2], [3,3]], "abscissas", "ordinates")

More complex plots with multiple lines must label each line—see the definition of LineSpec below.

plot("lines, plural",
     [["flat", [[1,2], [2,2], [3,2]]],
      ["steep", [[1,0], [2,10], [3,20]]]])

constant

PlotSpec: contract?

A PlotSpec is one of:
  • A LineSpec, for a graph with a single (unlabeled) line.

  • A non-empty vector whose elements are 2-element vectors, the first of which is the name of a line, and the second is a LineSpec for each line in the graph.

For example, this is a PlotSpec for a plot with a single line:
[[1,1], [2,2], [3,3]]

And this is also a PlotSpec, this one for a plot with two labeled lines:
[["flat", [[1,2], [2,2], [3,2]]],
 ["steep", [[1,0], [2,10], [3,20]]]]

constant

LineSpec: contract?

A LineSpec is a non-empty vector of PointSpec, and describes the points in a single line within a line plot.

constant

PointSpec: contract?

A PointSpec is a vector of two num?, which correspond to the x and y coordinate of a point, respectively.

constant

AxisSpec: contract?

An AxisSpec is a description of an axis—x or y. It is either:

constant

TransformSpec: contract?

Describing an axis with a TransformSpec applies a transformation to the axis. The TransformSpecs currently supported are: