Skip to main content

HexbinArtist

Struct HexbinArtist 

Source
pub struct HexbinArtist {
    pub x: Vec<f64>,
    pub y: Vec<f64>,
    pub gridsize: usize,
    pub cmap: Colormap,
    pub mincnt: usize,
    pub alpha: f64,
    pub color: Color,
    pub label: Option<String>,
    pub edgecolor: Option<Color>,
    pub show_colorbar: bool,
}
Expand description

A hexagonal binning (hexbin) plot that visualises point density on a 2D plane using a grid of flat-top hexagons.

Each hexagon is coloured according to the number of data points that fall within its boundaries, mapped through the configured Colormap. This is especially useful for large datasets where individual scatter points would overlap heavily.

Fields§

§x: Vec<f64>

X-coordinates of the raw data points.

§y: Vec<f64>

Y-coordinates of the raw data points.

§gridsize: usize

Number of hexagons across the x-axis. Default 20.

§cmap: Colormap

Colormap used to map bin counts to colors.

§mincnt: usize

Minimum point count for a hex to be drawn. Default 1.

§alpha: f64

Opacity from 0.0 (fully transparent) to 1.0 (fully opaque).

§color: Color

Primary color (used for legend swatch).

§label: Option<String>

Optional legend label.

§edgecolor: Option<Color>

Optional edge (stroke) color for hexagons.

§show_colorbar: bool

Whether to auto-attach a colorbar when this hexbin is drawn.

Implementations§

Source§

impl HexbinArtist

Source

pub fn data_bounds(&self) -> (f64, f64, f64, f64)

Computes the data-space bounding box (xmin, xmax, ymin, ymax).

Returns the extent of the finite x and y values. Falls back to (0.0, 1.0, 0.0, 1.0) when data is empty or entirely non-finite.

Source§

impl HexbinArtist

Source

pub fn gridsize(&mut self, gridsize: usize) -> &mut Self

Sets the number of hexagons across the x-axis.

Source

pub fn colormap(&mut self, cmap: Colormap) -> &mut Self

Sets the colormap used to map bin counts to colors.

Source

pub fn mincnt(&mut self, mincnt: usize) -> &mut Self

Sets the minimum count threshold; bins with fewer points are hidden.

Source

pub fn alpha(&mut self, alpha: f64) -> &mut Self

Sets the opacity from 0.0 (fully transparent) to 1.0 (fully opaque).

Source

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

Sets the legend label.

Source

pub fn edgecolor(&mut self, color: Color) -> &mut Self

Sets the hex edge (stroke) color.

Source

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

Enables or disables auto-attaching a colorbar when this hexbin is drawn.

Trait Implementations§

Source§

impl Clone for HexbinArtist

Source§

fn clone(&self) -> HexbinArtist

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HexbinArtist

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.