plotlib/lib.rs
1/*!
2
3# plotlib
4
5plotlib is a data plotting and rendering library.
6
7## Usage
8
9There are five different types of plot currently supported:
10
111. Box plot (`plotlib::repr::Box`)
121. Histogram (`plotlib::repr::Histogram`)
131. Line and scatter plot (`plotlib::repr::Plot`)
14
15## Technical
16
17Five main components of the plotlib pipeline:
18
191. Data
202. Representation
213. View
224. Page
235. Rendering
24
25**Data** is the plain Rust data structure that the user brings along.
26This might be something like a `Vec`, an `ndarray` or a slice.
27This will likely be copied or moved from to construct the *representation*.
28
29The **representation** is the transformed version of that data which is the base plot object.
30Each representation has N dimensions of input and one dimension of output.
31For example a scatter plot has x-values as inputs and for each of those a y-value as an output.
32A histogram has bins along one axis as its input and counts (or frequencies) as its output.
33A surface has x and y values as inputs and a z-value as its output.
34A function has some input value (mapped from the x-dimension) as its input
35and some value as its output which is projected onto the y-dimension.
36
37Each representation also contains a style which knows how it should look in the abstract.
38A concrete interpretation of this style is deferred to when the rendering happens.
39So a scatter plot will know what colour and style to use for the markers,
40and a histogram will know which colours to use for its bars.
41
42The **view** is how you want this data to be presented.
43Each dimension from the representation is mapped onto an axis.
44A view can contain multiple representations as long as they can be mapped on to the axes.
45For example a 2D 'matrix' histogram could be displayed as a flat grid or as a 3D LEGO plot.
46
47A **page** is the whole page. It can contain multiple views and specifies how they are laid out.
48
49Finally the **rendering** is the actual output.
50This could be an SVG, a PNG, an ASCII plot or an interactive web page.
51A rendering will not necessarily be able to show all types of views or representations
52and may choose to ignore some.
53
54This structure allows some data set to be represented multiple ways in one view
55or for a particular representation to be displayed across more than one view.
56
57Example
58
59- *Data*: A linear sequence of numbers as a Vec<f64>
60- *Representation*: A binned histogram, stored as a list of `Bin`s,
61 each of which is the bounds and the counts.
62 Blue bars with no casing.
63- *View*: Dimension 0 mapped to x-axis with range 5-19 and counts mapped to y-axis with range 0-60
64- *Page*: A single view on the page
65- *Rendering*: An SVG
66
67It starts from the end and works backwards.
68The Rendering (an SVG in this case) knows how to layout a *page*.
69It finds a single view inside and so creates the axes for it.
70It knows how to draw the axes for the view.
71It also knows how to draw each representation onto that view,
72in this case, interpreting the bins and colours to create SVG elements.
73
74*/
75
76pub mod grid;
77pub mod page;
78pub mod repr;
79pub mod style;
80pub mod view;
81
82mod axis;
83mod errors;
84mod svg_render;
85mod text_render;
86mod utils;