pub struct Axes { /* private fields */ }Expand description
A single set of axes within a figure, containing chart artists and configuration.
Users do not construct Axes directly; they are created by
[Figure::add_subplot] or the convenience function [Figure::subplots].
Once an Axes handle is obtained, chart methods such as plot,
scatter, and bar add data, and
configuration methods like set_title control labels,
limits, and styling.
Implementations§
Source§impl Axes
impl Axes
Sourcepub fn plot<X, Y>(&mut self, x: X, y: Y) -> Result<&mut LineArtist>where
X: IntoSeries,
Y: IntoSeries,
pub fn plot<X, Y>(&mut self, x: X, y: Y) -> Result<&mut LineArtist>where
X: IntoSeries,
Y: IntoSeries,
Plots a line connecting (x, y) data points.
Returns a mutable reference to the newly created LineArtist so
that the caller can chain builder methods (.color(), .width(),
.label(), etc.).
§Errors
Returns PlotError::SeriesLengthMismatch if x and y have
different lengths, or PlotError::EmptyData if either is empty.
Sourcepub fn scatter<X, Y>(&mut self, x: X, y: Y) -> Result<&mut ScatterArtist>where
X: IntoSeries,
Y: IntoSeries,
pub fn scatter<X, Y>(&mut self, x: X, y: Y) -> Result<&mut ScatterArtist>where
X: IntoSeries,
Y: IntoSeries,
Creates a scatter plot of (x, y) data points.
Returns a mutable reference to the ScatterArtist for chaining.
§Errors
Returns PlotError::SeriesLengthMismatch or PlotError::EmptyData
on invalid input.
Sourcepub fn bar<C, H>(&mut self, categories: C, heights: H) -> Result<&mut BarArtist>where
C: IntoCategories,
H: IntoSeries,
pub fn bar<C, H>(&mut self, categories: C, heights: H) -> Result<&mut BarArtist>where
C: IntoCategories,
H: IntoSeries,
Creates a vertical bar chart from categorical data and heights.
Each category label maps to one bar whose height is the corresponding
value in heights.
§Errors
Returns PlotError::SeriesLengthMismatch if categories and
heights have different lengths, or PlotError::EmptyData if empty.
Sourcepub fn barh<C, W>(&mut self, categories: C, widths: W) -> Result<&mut BarArtist>where
C: IntoCategories,
W: IntoSeries,
pub fn barh<C, W>(&mut self, categories: C, widths: W) -> Result<&mut BarArtist>where
C: IntoCategories,
W: IntoSeries,
Sourcepub fn hist<D>(&mut self, data: D, bins: usize) -> Result<&mut HistArtist>where
D: IntoSeries,
pub fn hist<D>(&mut self, data: D, bins: usize) -> Result<&mut HistArtist>where
D: IntoSeries,
Creates a histogram from raw data.
The data is partitioned into bins equal-width bins spanning the data
range, and each bin is drawn as a vertical bar whose height equals the
count of values falling in that bin.
§Errors
Returns PlotError::EmptyData if data is empty.
Sourcepub fn fill_between<X, Y1, Y2>(
&mut self,
x: X,
y1: Y1,
y2: Y2,
) -> Result<&mut FillBetweenArtist>
pub fn fill_between<X, Y1, Y2>( &mut self, x: X, y1: Y1, y2: Y2, ) -> Result<&mut FillBetweenArtist>
Fills the area between two y-series that share the same x values.
Useful for confidence intervals, envelopes, and area charts.
§Errors
Returns PlotError::SeriesLengthMismatch if any of the three
series differ in length, or PlotError::EmptyData if empty.
Sourcepub fn step<X: IntoSeries, Y: IntoSeries>(
&mut self,
x: X,
y: Y,
) -> Result<&mut StepArtist>
pub fn step<X: IntoSeries, Y: IntoSeries>( &mut self, x: X, y: Y, ) -> Result<&mut StepArtist>
Plots a step (staircase) chart connecting (x, y) data points.
Returns a mutable reference to the StepArtist for chaining.
§Errors
Returns PlotError::SeriesLengthMismatch or PlotError::EmptyData
on invalid input.
Sourcepub fn stem<X: IntoSeries, Y: IntoSeries>(
&mut self,
x: X,
y: Y,
) -> Result<&mut StemArtist>
pub fn stem<X: IntoSeries, Y: IntoSeries>( &mut self, x: X, y: Y, ) -> Result<&mut StemArtist>
Plots a stem (lollipop) chart from (x, y) data points.
Returns a mutable reference to the StemArtist for chaining.
§Errors
Returns PlotError::SeriesLengthMismatch or PlotError::EmptyData
on invalid input.
Sourcepub fn boxplot(&mut self, datasets: Vec<Vec<f64>>) -> Result<&mut BoxPlotArtist>
pub fn boxplot(&mut self, datasets: Vec<Vec<f64>>) -> Result<&mut BoxPlotArtist>
Creates a box-and-whisker plot from one or more data groups.
Each inner Vec<f64> produces one box. Groups are placed at integer
x-positions starting from 0.
§Errors
Returns PlotError::EmptyData if datasets is empty.
Sourcepub fn errorbar<X: IntoSeries, Y: IntoSeries>(
&mut self,
x: X,
y: Y,
) -> Result<ErrorBarArtist>
pub fn errorbar<X: IntoSeries, Y: IntoSeries>( &mut self, x: X, y: Y, ) -> Result<ErrorBarArtist>
Creates an error bar plot from (x, y) data points.
Returns an owned ErrorBarArtist that can be configured with
builder methods (.yerr_symmetric(), .cap_size(), etc.) and then
added to the axes via add_errorbar.
§Errors
Returns PlotError::SeriesLengthMismatch or PlotError::EmptyData
on invalid input.
Sourcepub fn add_errorbar(&mut self, artist: ErrorBarArtist)
pub fn add_errorbar(&mut self, artist: ErrorBarArtist)
Adds a finalized ErrorBarArtist to the axes.
Use this after configuring the artist returned by
errorbar.
Sourcepub fn heatmap(&mut self, data: Vec<Vec<f64>>) -> Result<&mut HeatmapArtist>
pub fn heatmap(&mut self, data: Vec<Vec<f64>>) -> Result<&mut HeatmapArtist>
Creates a heatmap from a 2D grid of values.
Returns a mutable reference to the HeatmapArtist for chaining
builder methods (.colormap(), .vmin(), .show_values(), etc.).
§Errors
Returns PlotError::EmptyData if data is empty.
Source§impl Axes
impl Axes
Sourcepub fn set_title(&mut self, title: &str) -> &mut Self
pub fn set_title(&mut self, title: &str) -> &mut Self
Sets the title displayed above the axes area.
Sourcepub fn set_xlabel(&mut self, label: &str) -> &mut Self
pub fn set_xlabel(&mut self, label: &str) -> &mut Self
Sets the x-axis label.
Sourcepub fn set_ylabel(&mut self, label: &str) -> &mut Self
pub fn set_ylabel(&mut self, label: &str) -> &mut Self
Sets the y-axis label.
Sourcepub fn set_xlim(&mut self, min: f64, max: f64) -> &mut Self
pub fn set_xlim(&mut self, min: f64, max: f64) -> &mut Self
Sets explicit x-axis limits. Pass (min, max).
Sourcepub fn set_ylim(&mut self, min: f64, max: f64) -> &mut Self
pub fn set_ylim(&mut self, min: f64, max: f64) -> &mut Self
Sets explicit y-axis limits. Pass (min, max).
Sourcepub fn set_xscale(&mut self, scale: Scale) -> &mut Self
pub fn set_xscale(&mut self, scale: Scale) -> &mut Self
Sets the x-axis scale (linear, log10, symlog).
Sourcepub fn set_yscale(&mut self, scale: Scale) -> &mut Self
pub fn set_yscale(&mut self, scale: Scale) -> &mut Self
Sets the y-axis scale (linear, log10, symlog).
Sourcepub fn set_legend_loc(&mut self, loc: Loc) -> &mut Self
pub fn set_legend_loc(&mut self, loc: Loc) -> &mut Self
Sets the legend location.