Expand description
§plotkit
Publication-quality plots in 3 lines of Rust.
let x: Vec<f64> = (0..100).map(|i| i as f64 * 0.1).collect();
let y: Vec<f64> = x.iter().map(|&v| v.sin()).collect();
plotkit::plot(&x, &y).unwrap();
plotkit::title("sin(x)");
plotkit::savefig("plot.png").unwrap();§Two APIs
pyplot-style (quick scripts):
let x = vec![0.0_f64, 1.0, 2.0];
let y = vec![0.0_f64, 1.0, 4.0];
plotkit::plot(&x, &y).unwrap();
plotkit::savefig("out.png").unwrap();Figure/Axes (full control):
use plotkit::prelude::*;
let mut fig = Figure::with_size(800, 600);
let ax = fig.add_subplot(1, 1, 1);
// ax.plot(&x, &y).unwrap().label("sin(x)");
// ax.legend();Re-exports§
pub use plotkit_ndarray;pub use plotkit_polars;
Modules§
- annotations
- Text annotations and arrow annotations for axes.
- artist
- Artist types – data + styling for each visual chart element.
- axes
- The Axes container – holds chart data and renders a single subplot.
- charts
- Chart builder methods for configuring visual properties.
- colorbar
- Colorbar component for displaying color-to-value mappings.
- colormap
- Named colormap system for mapping scalar values to colors.
- error
- Error types for plotkit.
- figure
- The top-level Figure container.
- jupyter
- Jupyter notebook display support via evcxr.
- layout
- Layout engine for computing plot area and margins.
- legend
- Legend layout and rendering.
- prelude
- The plotkit prelude — import this for convenient access to all common types.
- primitives
- Core primitive types for plotkit rendering.
- renderer
- The renderer trait — the single seam between chart logic and output backends.
- scale
- Axis scale transformations (data space → axes space).
- series
- Data series abstraction for chart input.
- theme
- Theme system controlling all visual defaults.
- ticks
- Axis tick generation using the Talbot/Wilkinson extended algorithm.
Structs§
- Annotation
- An annotation with optional arrow from a text position to a data point.
- Axes
- A single set of axes within a figure, containing chart artists and configuration.
- Color
- An RGBA color with 8 bits per channel.
- Figure
- A figure is the top-level container for one or more axes (subplots).
- Text
Annotation - A text label placed at a data-space coordinate.
- Theme
- Visual theme controlling all rendering defaults.
Enums§
- Arrow
Style - Arrow style for annotations connecting text to a data point.
- Grid
Axis - Which axes should display grid lines.
- HAlign
- Horizontal text alignment.
- Line
Style - Line drawing style.
- Loc
- Legend location relative to the axes area.
- Marker
- Scatter plot marker shape.
- Plot
Error - Errors that can occur in plotkit operations.
- Scale
- A scale maps data values to the normalized [0, 1] range for axis display.
- Twin
Side - Specifies which side a twin axes occupies relative to its parent.
- VAlign
- Vertical text alignment.
Traits§
- Figure
Ext - Extension trait adding save methods to Figure.
- Into
Categories - Trait for types that can be converted into
Categories. - Into
Series - Trait for types that can be converted into a
Series.
Functions§
- bar
- Creates a bar chart on the current figure.
- clf
- Clears the current figure.
- grid
- Enables or disables grid lines on the current axes.
- hist
- Creates a histogram on the current figure.
- legend
- Shows the legend on the current axes.
- plot
- Plots a line on the current figure.
- save_
figure - Saves a figure to a file, selecting the renderer by file extension.
- savefig
- Saves the current figure to a file. Format is determined by extension (.png, .svg).
- scatter
- Creates a scatter plot on the current figure.
- subplots
- Replaces the current figure with an
nrows × ncolssubplot grid. - title
- Sets the title of the current axes.
- xlabel
- Sets the x-axis label.
- xlim
- Sets explicit x-axis limits on the current axes.
- xscale
- Sets the x-axis scale on the current axes.
- xticks
- Sets custom x-axis tick positions on the current axes.
- ylabel
- Sets the y-axis label.
- ylim
- Sets explicit y-axis limits on the current axes.
- yscale
- Sets the y-axis scale on the current axes.
- yticks
- Sets custom y-axis tick positions on the current axes.
Type Aliases§
- Result
- A specialized Result type for plotkit operations.