plot/point
src/plot/point.tur
defstruct
PointsR
(defstruct PointsR :copy [points : (Vec Point) style : PointStyle label : cstr])
a scatter of its points.
defstruct
ErrorBarsR
(defstruct ErrorBarsR :copy [bars : (Vec ErrorBar) style : LineStyle horizontal : bool label : cstr])
error bars spanning y +/- err, or x +/- err when
defstruct
VectorFieldR
(defstruct VectorFieldR :copy [f : (fn [float float])
the direction f(x, y) (a Point: dx, dy) drawn on a samples x samples grid
defstruct
ArrowsR
(defstruct ArrowsR :copy [arrows : (Vec Arrow) style : LineStyle label : cstr])
explicit arrows.
defn
points
(points [vs : (Vec Point) style : PointStyle label : cstr] :)
scatter plot renderer.
Parameters
| vs | the points | |
| style | the PointStyle of the markers | |
| label | legend text ("" for none) |
Returns
A PointsR boxed as an AnyRenderer.
Example
(points (vec-of (Point 1.0 2.0) (Point 2.0 3.5)) (default-point-style) "samples")
defn
error-bars
(error-bars [bars : (Vec ErrorBar) style : LineStyle horizontal : bool label : cstr] :)
vertical or horizontal error bars.
Parameters
| bars | the error bars | |
| style | the LineStyle to stroke with | |
| horizontal | true for x +/- err, false for y +/- err | |
| label | legend text ("" for none) |
Returns
An ErrorBarsR boxed as an AnyRenderer.
Example
(error-bars (vec-of (ErrorBar 1.0 2.0 0.25)) (default-line-style) false "err")
defn
vector-field
(vector-field [^fat f : (fn [float float])
draw the direction f(x, y) at each point of a grid.
Parameters
| f | the field, a (fn [float float] Point) giving (dx, dy) | |
| x-min | left edge of the sampled domain | |
| x-max | right edge of the sampled domain | |
| y-min | bottom edge of the sampled domain | |
| y-max | top edge of the sampled domain | |
| samples | grid points per axis | |
| scale-mode | 0 raw, 1 normalised, 2 raw at a larger scale | |
| style | the LineStyle to stroke with | |
| label | legend text ("" for none) |
Returns
A VectorFieldR boxed as an AnyRenderer.
Example
(vector-field (fn [x : float y : float] : Point (Point (- 0.0 y) x))
-1.0 1.0 -1.0 1.0 8 1 (default-line-style) "field")
defn
arrows
(arrows [arrow-list : (Vec Arrow) style : LineStyle label : cstr] :)
explicit arrow segments.
Parameters
| arrow-list | the arrows | |
| style | the LineStyle to stroke with | |
| label | legend text ("" for none) |
Returns
An ArrowsR boxed as an AnyRenderer.
Example
(arrows (vec-of (Arrow 0.0 0.0 1.0 1.0)) (default-line-style) "moves")
Internal definitions
__draw-points-- fill and outline a marker at each lowered point.__draw-error-bars-- stroke each lowered (x . (y . h)) bar, x +/- h when `horizontal`.__draw-arrows-- stroke each lowered (x1 . (y1 . (x2 . y2))) segment with a head.__draw-vector-field-- stroke the direction f(x, y) on a grid x grid lattice.Renderer[PointsR]Renderer[ErrorBarsR]Renderer[VectorFieldR]Renderer[ArrowsR]