Skip to main content

Module plot

Module plot 

Source
Expand description

A fast, interactive 2D plot in the spirit of matplotlib.

  • Series: lines, areas, steps, scatter with seven markers, bars, error bars, functions, and horizontal/vertical reference lines; plus pie/donut slices, candlesticks, heatmaps, radar polygons, gauges, and waterfalls.
  • Axes: linear or log10 scales, 1-2-5 ticks that never overlap, minor log ticks, grid, and a title and axis titles with their own size, color, and alignment; every line is snapped to the pixel grid.
  • Two y axes: series marked YAxis::Right get their own axis on the right, with its own range, scale, ticks, and title.
  • Legend hover animations: 13 effects with user-defined easing, plus a direction arrow beside the newest sample of streaming line series.
  • Interaction: drag to pan, wheel to zoom around the cursor (Shift: x only, Alt: y only; with two y axes, Alt zooms the left axis over the left half of the frame and the right axis over the right half), right-drag or the zoom tool to zoom to a box, Shift-drag or the select tool to select an area, double-click to fit the data again, and a hover popup with the nearest point. A small toolbar switches tools; the legend toggles series and can be dragged anywhere inside the frame (the position lives in the PlotState).
  • Lines can be smoothed with a spline or a monotone cubic (Smoothing).
  • Analysis: least-squares fits (Fit) with their equation and R².
  • Speed: dense sorted lines are decimated per pixel column, so a million points draw in a few milliseconds; nothing repaints while idle.

Plot3D is the 3D sibling: an orbit camera, x/y/z axes, lines, scatter, bars, and surfaces, with the same legend, hover animations, direction arrow, themes, and SVG/PNG export.

The view, the selection, the active tool, and hidden series live in a PlotState the caller owns, like every other component.

Structs§

AxisConfig
One axis: range, scale, ticks, grid, and labels.
Bounds
An axis-aligned range in data space.
Bounds3D
An axis-aligned range in 3D data space.
Camera3D
An orbit camera: angles, distance, target, field of view, and projection.
Complex
A complex sample for the FFT.
CurveAreaSummary
The numbers behind a curve-vs-chord measurement.
DatasetPlot
A plot builder over two numeric dataset columns.
DirectionArrowConfig
Settings for the direction arrow drawn beside the newest point of a line.
DistanceSummary
The numbers behind a distance measurement.
ExportOptions
Export settings.
Extremum
One local extremum of a series inside a region.
FilterSettings
Parameters shared by the filters.
Fit
A fitted model: its coefficients, its goodness of fit, and an evaluator.
GaugeConfig
Layout of gauge charts.
HeatmapConfig
Layout of heatmaps.
LegendHoverConfig
Settings for the legend hover animation.
MeasurementConfig
Measurement settings owned by the chart configuration.
ModelFit
A fitted parameter set with standard errors.
Peak
One detected peak: index and height.
PieConfig
Layout of pie and donut charts.
Pipeline
The ordered filter chain and the optional transform.
Plot
The plot builder. Add series, then call show with the icon cache and a PlotState.
Plot3D
The 3D plot builder. Add series, then call show with the icon cache and a Plot3DState.
Plot3DConfig
The complete appearance of a 3D plot.
Plot3DHover
The nearest 3D data point under the pointer.
Plot3DResponse
What happened in the 3D plot this frame.
Plot3DState
The interactive state of one 3D plot. Keep it in the application model.
PlotColors
Optional color overrides; None follows the theme.
PlotConfig
The complete appearance of a plot.
PlotGrid
A rows × columns grid of plots. Every plot shares the same PlotState, so pan, zoom, hidden series, and selection stay linked.
PlotHover
The nearest data point under the pointer.
PlotResponse
What happened in the plot this frame.
PlotState
The interactive state of one plot. Keep it in the application model.
RadarConfig
Layout of radar charts. One series draws one closed polygon; several series overlay.
Series
One named data series. Build it with Series::line, Series::scatter, Series::bars, Series::area, Series::step, Series::function, Series::hline, or Series::vline, then add it to a super::Plot.
Series3D
One named 3D data set. Build it with Series3D::line, Series3D::scatter, Series3D::bars, Series3D::surface, or Series3D::surface_fn, then add it to a super::Plot3D.
Series3DStyle
Overrides for one 3D series, matched by name.
SeriesMeasurement
What one series contributes to an area measurement.
SeriesStyle
Overrides for one series, matched by name.
Statistics
Summary statistics of a selection.
Surface
A regular surface: x columns, y rows, and row-major z values.
Surface3DConfig
Fill, lines, and color scale of a surface.
TransformSettings
Parameters shared by the transforms.
ViewHistory
A bounded back/forward history of plot views.
WaterfallConfig
Layout of waterfall charts.

Enums§

AnimationEasing
How the animation’s clock is shaped within one cycle.
ChartMode
The family of a plot, inferred from its series.
Colormap
A color scale for heatmaps and colorbars.
DatasetPlotKind
How a dataset series is drawn.
ExportFormat
A file format the toolbar’s export menu asked for.
ExportPreset
Common export sizes.
FilterKind
A filter available from the analysis menu.
FitKind
The model to fit.
LegendAnimation
The animation played while the pointer rests on a legend row.
LegendPosition
Where the legend sits inside the frame.
LineStyle
How a line is stroked.
Marker
Point markers for scatter series and line vertices.
MeasurementAreaStyle
Which area a curve-segment label shows first.
MeasurementMode
How the area tool measures.
Minor
How many minor ticks sit between two major ticks.
Plot3DTool
What a primary-button drag does in a 3D plot.
PlotAnnotation
A text note, arrow, span, or region drawn in data coordinates.
PlotMeasurement
A persistent measurement drawn over the data.
PlotTool
What a primary-button drag does.
Projection
How the camera projects depth.
Renderer
Which renderer draws the data layer.
Scale
How values map onto an axis.
Smoothing
How a line passes through its points.
TitleAlign
Where the chart title sits along the top.
TransformKind
A transform available from the analysis menu.
YAxis
Which vertical axis a series is measured against.

Traits§

PipelineSeries
Apply a core pipeline to plot series.

Functions§

box_plot
A box plot at x = 0: box, median, whiskers, and caps.
contour
A contour line of a regular grid at level, as one series with NaN breaks.
curve_area_summary
Compute the curve-vs-chord summary for a PlotMeasurement::CurveArea.
derivative
Central-difference derivative; the ends use one-sided differences.
fft
In-place radix-2 FFT. The length must be a power of two.
find_peaks
Detect local maxima above min_height, at least min_distance samples apart.
fit_model
Gauss–Newton fit with numerical Jacobians and Levenberg damping.
hexbin
A regular hexbin/2D-density grid of [x, y, count] cells, ready for Series::heatmap.
histogram
A histogram of values as centered bars.
histogram_density
A histogram normalized so the bar areas sum to one; a density estimate appears as a line over the same bars.
integral
Trapezoidal integral, with the running area at every sample.
points_in
Indices of the points of data inside bounds (data space), for selections.
polar
Convert polar samples (theta, radius) to a cartesian line.
region_measurements
The statistics of every visible series inside bounds.
region_size
A rectangle’s data-space width/height, useful for an editor.
remove_baseline
Subtract a rolling baseline in place.
resample
Linear resampling to len samples.
rolling_baseline
A rolling-minimum baseline. window is clamped to an odd number of samples.
savgol
Savitzky–Golay smoothing. Returns the same length; the edges are clamped.
savgol_derivative
Savitzky–Golay first derivative, per sample step.
set_output_formatgpu
Set the host’s wgpu surface format. Returns whether the format is supported.
show_colorbar
A colorbar widget for an existing colormap, drawn at the current cursor.
smith
Convert impedance samples (resistance, reactance) to a Smith-chart reflection line.
spectrum
A one-sided magnitude spectrum: [frequency, magnitude] up to Nyquist.
to_unicode_math
Convert a LaTeX subset to Unicode text.
violin
A violin outline from a Gaussian kernel density estimate, centered at x = 0.

Type Aliases§

Model
A nonlinear model f(x, params) for fit_model.