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.
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.