plot/contour
src/plot/contour.tur
defstruct
IsolineR
(defstruct IsolineR :copy [f : (fn [float float])
the single contour f(x, y) = level.
defstruct
ContoursR
(defstruct ContoursR :copy [f : (fn [float float])
`levels` contours in one style, spaced evenly through the
defstruct
ContourIntervalsR
(defstruct ContourIntervalsR :copy [f : (fn [float float])
f(x, y) over [0, 1] split into `bands` + 1 filled
defstruct
ColorFieldR
(defstruct ColorFieldR :copy [f : (fn [float float])
each grid cell filled with palette color f(x, y), at `alpha`.
defn
isoline
(isoline [^fat f : (fn [float float])
draw a single f(x,y)=level contour.
Parameters
| f | the field, a (fn [float float] float) | |
| 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 (at least 8) | |
| level | the contour value | |
| style | the LineStyle to stroke with | |
| label | legend text ("" for none) |
Returns
An IsolineR boxed as an AnyRenderer.
Example
(isoline saddle -2.0 2.0 -2.0 2.0 32 0.0 (default-line-style) "zero")
defn
contours
(contours [^fat f : (fn [float float])
draw n contour levels spaced evenly through f's range.
Parameters
| f | the field, a (fn [float float] float) | |
| 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 (at least 8) | |
| n | number of levels | |
| style | the LineStyle of every level | |
| label | legend text ("" for none) |
Returns
A ContoursR boxed as an AnyRenderer.
Example
(contours saddle -2.0 2.0 -2.0 2.0 32 4 (default-line-style) "levels")
defn
contour-intervals
(contour-intervals [^fat f : (fn [float float])
fill contour bands using sampled cells.
Parameters
| f | the field, a (fn [float float] float), banded over [0, 1] | |
| 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 (at least 8) | |
| n | number of band boundaries (n + 1 bands) | |
| fills | the FillStyle of each band, in order | |
| label | legend text ("" for none) |
Returns
A ContourIntervalsR boxed as an AnyRenderer.
Example
(contour-intervals saddle -2.0 2.0 -2.0 2.0 32 3 (vec-of lo mid hi) "bands")
defn
color-field
(color-field [^fat f : (fn [float float])
color sampled cells by f(x,y)->color-idx.
Parameters
| f | the coloring, a (fn [float float] int) returning a palette index | |
| 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 (at least 8) | |
| alpha | cell opacity |
Returns
A ColorFieldR boxed as an AnyRenderer.
Example
(color-field quadrant -2.0 2.0 -2.0 2.0 32 0.35)
Internal definitions
__draw-color-field-- fill each grid cell with palette color f(cell center).__draw-contour-bands-- fill each grid cell with the fill of the band (of__draw-contour-lines-- stroke the f(x, y) = level contours by marchingRenderer[IsolineR]Renderer[ContoursR]Renderer[ContourIntervalsR]Renderer[ColorFieldR]