Skip to main content

Axes

Struct Axes 

Source
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

Source

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.

Source

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.

Source

pub fn bar<C, H>(&mut self, categories: C, heights: H) -> Result<&mut BarArtist>

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.

Source

pub fn barh<C, W>(&mut self, categories: C, widths: W) -> Result<&mut BarArtist>

Creates a horizontal bar chart from categorical data and widths.

Behaves like bar but draws horizontal bars from the y-axis.

§Errors

Same as bar.

Source

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.

Source

pub fn fill_between<X, Y1, Y2>( &mut self, x: X, y1: Y1, y2: Y2, ) -> Result<&mut FillBetweenArtist>
where X: IntoSeries, Y1: IntoSeries, Y2: IntoSeries,

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

Source

pub fn set_title(&mut self, title: &str) -> &mut Self

Sets the title displayed above the axes area.

Source

pub fn set_xlabel(&mut self, label: &str) -> &mut Self

Sets the x-axis label.

Source

pub fn set_ylabel(&mut self, label: &str) -> &mut Self

Sets the y-axis label.

Source

pub fn set_xlim(&mut self, min: f64, max: f64) -> &mut Self

Sets explicit x-axis limits. Pass (min, max).

Source

pub fn set_ylim(&mut self, min: f64, max: f64) -> &mut Self

Sets explicit y-axis limits. Pass (min, max).

Source

pub fn set_xscale(&mut self, scale: Scale) -> &mut Self

Sets the x-axis scale (linear, log10, symlog).

Source

pub fn set_yscale(&mut self, scale: Scale) -> &mut Self

Sets the y-axis scale (linear, log10, symlog).

Source

pub fn grid(&mut self, show: bool) -> &mut Self

Enables or disables grid lines on this axes.

Source

pub fn legend(&mut self) -> &mut Self

Enables the legend on this axes.

Source

pub fn set_legend_loc(&mut self, loc: Loc) -> &mut Self

Sets the legend location.

Source

pub fn set_theme(&mut self, theme: Theme) -> &mut Self

Overrides the figure theme for this axes only.

Trait Implementations§

Source§

impl Debug for Axes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Axes

§

impl RefUnwindSafe for Axes

§

impl Send for Axes

§

impl Sync for Axes

§

impl Unpin for Axes

§

impl UnsafeUnpin for Axes

§

impl UnwindSafe for Axes

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.