1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*!
* # plotive
* _declarative plotting_. A simple data plotting library written in Rust
*
* Plotive separates figure design from data representation and from rendering surfaces.
*
* ## Supported figure types
* - XY line plots
* - Scatter plots
* - Histograms
* - Bar plots
*
*
* ## Get started
*
* Add `plotive` to your project, as well as one of the surface backend crates.<br />
* (here `plotive-iced`, a GUI crate for [iced.rs](https://iced.rs))
*
* ```text
* cargo add plotive
* cargo add plotive-iced
* ```
*
* Here is a quick tuto and example to create your first figure:
*
* ```no_run
* # use std::f64::consts::PI;
* # use std::sync::Arc;
* # fn main() {
* // We start by the figure design. We need the `des` module for that.
* use plotive::des;
*
* // Create the axes. They are empty by default.
* // We add titles, ticks and grids to the axes.
* let x_axis = des::Axis::new()
* // the title can be built from a String or a `plotive_text::RichText` object
* .with_title("x".into())
* .with_ticks(
* // we specify a tick locator that places ticks at multiples of pi
* des::axis::Ticks::new().with_locator(
* des::axis::ticks::PiMultipleLocator::default().into()
* ),
* )
* // add default grid on major ticks
* .with_grid(Default::default());
*
* // similarly for the y axis, with minor ticks and grid as well
* let y_axis = des::Axis::new()
* .with_title("y".into())
* .with_ticks(Default::default())
* .with_grid(Default::default())
* .with_minor_ticks(Default::default())
* .with_minor_grid(Default::default());
*
* // Create a line series.
* // We don't provide data just yet, we reference instead data columns "x" and "y".
* // It is also possible to provide data inline in the design if it fits your need.
* // (If so, supply `()` as data source when creating the figure below)
* let series = des::series::Line::new(des::data_src_ref("x"), des::data_src_ref("y"))
* // name the series for the legend
* .with_name("y=sin(x)")
* .into();
*
* // Create the plot with what we just built,
* // and add a legend at top-right inside the plot area
* let plot = des::Plot::new(vec![series])
* .with_x_axis(x_axis)
* .with_y_axis(y_axis)
* .with_legend(des::plot::LegendPos::InTopRight.into());
*
* // We can now finalize our design by creating the figure from the plot.
* // `des::Figure` is the top-level design object in plotive.
* let fig = des::Figure::new(plot.into()).with_title("a sine wave".into());
*
* // We can now create the data source for the figure.
* use plotive::data;
*
* let x: Vec<f64> = (0..=360).map(|t| t as f64 * PI / 180.0).collect();
* let y = x.iter().map(|x| x.sin()).collect();
*
* // This is a simple source type, that takes ownership of the data.
* let data_source = data::TableSource::new()
* .with_f64_column("x", x)
* .with_f64_column("y", y);
*
* // Finally, we can show the figure using the `Show` trait from the `plotive-iced` crate.
* use plotive_iced::{show, Show};
*
* // To implement zooming and panning, `Show` needs to keep a reference
* // to the data source, so we wrap it in an Arc.
* // It means that `Show` doesn't support data sources that borrow data.
* // But `plotive-pxl` and `plotive-svg` do support borrowed data sources.
*
* fig.show(
* Arc::new(data_source),
* // We specify light theme style for the figure.
* // Default would follow the default theme of the iced window. (system light/dark mode)
* show::Params {
* style: Some(plotive::Style::light()),
* ..Default::default()
* },
* )
* .unwrap();
* # }
* ```
*
* This should open the following window:
* 
*
*
* ## Crate features
*
* - `data-csv`: enables CSV data source support (See [`data::csv`])
* - `data-polars`: enables [Polars](https://pola.rs) data source support (See [`data::polars`])
* pulls in the `polars` dependency, which is quite a beast to compile.
* - `dsl`: enables the support for `.plotive` DSL. (See [`dsl`] and [`plotive-dsl` crate](https://crates.io/crates/plotive-dsl))
* - `noto-mono`, `noto-sans`, `noto-sans-italic`, `noto-serif`, `noto-serif-italic`: bundles the corresponding fonts from Google in the final executable, and enables `plotive::bundled_font_db()`.<br />
* `noto-sans` is enabled by default
* - `time`: enables support for time series, CSV date-time parsing etc. (See [`time`])
* - `utils`: enables various utilities such as `linspace`, `logspace` etc. (See [`utils`])
*
*
* ## Notes about plotive's design
*
* The figure design lies in the [`des`] module.
* This module describes the figure design in a declarative way. It ignores everything about the rendering surfaces.
* This will allow to bridge easily plotive to other programming languages and to write a compiler for plotive figures.
*
* The rendering surfaces implements the [`render::Surface`] trait and are in separate crates.
* (see `plotive-pxl`, `plotive-svg`, `plotive-iced`)
* The rendering surfaces themselves ignore everything about figure design and the `des` module.
* They focus on rendering primitives, like rects and paths. Even text is pre-processed to paths before reaching the surface.
* This allows to easily add new rendering surfaces to plotive.
*
* [`des`] and [`render`] are bridged together by the [`drawing`] module, which exposes very little public API.
* This module draws a [`des::Figure`] onto a [`render::Surface`] and acts in two phases:
* - preparation: [`drawing::Prepare::prepare()`] returns a [`drawing::PreparedFigure`], which caches all the layout information,
* the text preprocessed as paths, the series data converted to paths, etc.
* - drawing: [`drawing::PreparedFigure::draw()`] draws the prepared figure onto the surface, using the cached information. Themes
* colors are resolved at this stage.
*
* The [`drawing::PreparedFigure`] has API to update the series with new data, so that dynamic plots can be implemented easily and efficiently.
* It also supports zooming and panning operations.
*
*/
// Plotive is released under the MIT License with the following copyright:
// Copyright (c) 2025-2026 Rémi Thebault
pub use Prepare;
pub use Style;
/// Rexports of [`plotive_base::color`]` items
pub use ;
/// Rexports of [`plotive_base::geom`]` items
/// Rexports of [`plotive_text`]` items
/// Loads fonts that are bundled with plotive
/// and returns the database.
pub use bundled_font_db;
pub use fontdb;
/// Module containing missing configuration values
/// Basically we put here all magic values that would require proper parameters
pub