Macro debug_plotter::plot [−][src]
macro_rules! plot {
($($($variable : ident) ? $(($x : ident, $y : ident)) ? $(as $name : literal)
?), * $(,) ? $(where $($key : ident = $value : expr), * $(,) ?) ?) => { ... };
}
Expand description
This macro is used to quickly generate plots for a list of variables.
All types that implement num_traits::cast::ToPrimitive
can be plotted.
The macro takes a list of variables. By default, the value of the variable is mapped to the y axis, and the x axis shows the iteration number.
debug_plotter::plot!(a, b, c);
It is possible to pass a tuple if you want the x axis to be another value instead of the iteration number.
debug_plotter::plot!((x, a), (x, b), (x, c));
It is also possible to rename variables in the legend using the keyword as
.
debug_plotter::plot!(a as "Alice", b as "Bob", c as "Charlie");
It is possible to provide additional options for the plot
after a where
keyword.
debug_plotter::plot!(a, b, c where caption = "My Caption");
The following table lists all available options.
Identifier | Example Value | Description |
---|---|---|
caption | "caption" | Sets the caption of the plot. |
size | (400, 300) | Sets the size of the resulting image. |
x_desc | "x description" | Sets the description of the x axis. |
y_desc | "y description" | Sets the description of the y axis. |
path | "/plots/my_plot.jpg" | Defines where the plot is saved. |
x_range | 0f64..100f64 | Defines start and end of the x axis. |
y_range | 0f64..100f64 | Defines start and end of the y axis. |