plot/area
src/plot/area.tur
defstruct
RectanglesR
(defstruct RectanglesR :copy [rects : (Vec Rect) fill : FillStyle label : cstr])
rectangles in one fill.
defstruct
AreaHistogramR
(defstruct AreaHistogramR :copy [bars : (Vec Rect) fills : (Vec FillStyle) label : cstr])
pre-bucketed bars, each a Rect taking the next style
defstruct
DiscreteHistogramR
(defstruct DiscreteHistogramR :copy [bars : (Vec Bar) fill : FillStyle horizontal : bool label : cstr])
one Bar per category slot 0, 1, 2, ...;
defstruct
StackedHistogramR
(defstruct StackedHistogramR :copy [groups : (Vec Group) fills : (Vec FillStyle) labels : (Vec cstr) horizontal : bool])
one Group per category slot, a stack of its values,
defn
rectangles
(rectangles [rects : (Vec Rect) fill : FillStyle label : cstr] :)
draw filled rectangles.
Parameters
| rects | the rectangles | |
| fill | the FillStyle of the rectangles | |
| label | legend text ("" for none) |
Returns
A RectanglesR boxed as an AnyRenderer.
Example
(rectangles (vec-of (Rect 0.0 1.0 0.0 2.0)) (default-fill-style) "boxes")
defn
area-histogram
(area-histogram [bars : (Vec Rect) fill-styles : (Vec FillStyle) label : cstr] :)
draw pre-bucketed bars with cycling fills.
Parameters
| bars | the bars, each a Rect | |
| fill-styles | the FillStyle of each bar, in order (the default past the end) | |
| label | legend text ("" for none) |
Returns
An AreaHistogramR boxed as an AnyRenderer.
Example
(area-histogram buckets (vec-of (fill-style 0 0.5 -1 0.0) (fill-style 1 0.5 -1 0.0)) "hist")
defn
discrete-histogram
(discrete-histogram [bars : (Vec Bar) fill : FillStyle horizontal : bool label : cstr] :)
categorical bar chart.
Parameters
| bars | one Bar per category | |
| fill | the FillStyle of the bars | |
| horizontal | true to lay the bars along the y axis | |
| label | legend text ("" for none) |
Returns
A DiscreteHistogramR boxed as an AnyRenderer.
Example
(discrete-histogram (vec-of (Bar "a" 3.0) (Bar "b" 5.0)) (default-fill-style) false "counts")
defn
stacked-histogram
(stacked-histogram [groups : (Vec Group) fills : (Vec FillStyle) labels : (Vec cstr) horizontal : bool] :)
stacked categorical bars.
Parameters
| groups | one Group per category | |
| fills | the FillStyle of each stack layer (the default past the end) | |
| labels | the layer names, listed in the legend | |
| horizontal | true to lay the stacks along the y axis |
Returns
A StackedHistogramR boxed as an AnyRenderer.
Example
(stacked-histogram (vec-of (Group "Q1" (vec-of 1.0 0.5)) (Group "Q2" (vec-of 1.25 0.75)))
(vec-of (default-fill-style) (default-fill-style))
(vec-of "base" "extra") false)
Internal definitions
__draw-rects-- fill each (x0 . (x1 . (y0 . y1))) quad with `fill`.__draw-area-hist-- fill each (x0 . (x1 . (y0 . y1))) bar with the next__draw-discrete-hist-- fill a 0.8-wide bar per (label . height) at slots__draw-stacked-hist-- fill each (label . values) slot as a stack, each__bar-labels-- the tick labels of `bars[i..n)` pushed onto `out`.__copy-labels-- `labels[i..n)` pushed onto `out`.__group-labels-- the tick labels of `groups[i..n)` pushed onto `out`.Renderer[RectanglesR]Renderer[AreaHistogramR]Renderer[DiscreteHistogramR]Renderer[StackedHistogramR]