Skip to main content

ScatterArtist

Struct ScatterArtist 

Source
pub struct ScatterArtist {
    pub x: Series,
    pub y: Series,
    pub color: Color,
    pub marker: Marker,
    pub size: f64,
    pub label: Option<String>,
    pub alpha: f64,
    pub colors: Option<Vec<Color>>,
    pub c: Option<Vec<f64>>,
    pub cmap: Option<Colormap>,
}
Expand description

A scatter plot rendering individual markers at (x, y) positions.

Each data point is drawn as a marker whose shape, size, and color can be configured. An optional per-point colors vector overrides the uniform color field, enabling colormap-based visualizations.

Fields§

§x: Series

X-coordinates of the data points.

§y: Series

Y-coordinates of the data points.

§color: Color

Default marker color (used when colors is None).

§marker: Marker

Marker shape.

§size: f64

Marker diameter in pixels.

§label: Option<String>

Optional legend label. When Some, the scatter appears in the legend.

§alpha: f64

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

§colors: Option<Vec<Color>>

Optional per-point colors for colormap-driven scatter plots.

When set, colors.len() must equal x.len() (and y.len()). Each entry overrides color for the corresponding data point.

§c: Option<Vec<f64>>

Optional per-point scalar values for colormap-driven coloring.

When set together with cmap, each value is mapped through the colormap to produce per-point colors. Takes precedence over colors.

§cmap: Option<Colormap>

Optional colormap used to map c values to colors.

Implementations§

Source§

impl ScatterArtist

Source

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

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

Falls back to (0.0, 1.0) on each axis when the corresponding series contains no finite values.

Source§

impl ScatterArtist

Source

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

Sets the marker color.

Applies the given Color to every marker rendered by this artist, unless per-point colors have been set via colors.

§Arguments
  • color - The Color to fill each marker with.
§Examples
artist.color(Color::TAB_RED);
Source

pub fn marker(&mut self, marker: Marker) -> &mut Self

Sets the marker shape.

The Marker enum defines the available shapes (circle, square, triangle, diamond, plus, cross, star, point). The default is Marker::Circle.

§Arguments
  • marker - The Marker variant to use for every data point.
§Examples
artist.marker(Marker::Triangle);
Source

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

Sets the marker size in pixels.

This controls the diameter of each marker glyph. Larger values produce more prominent data points; smaller values suit dense scatter plots.

§Arguments
  • size - The marker diameter in device-independent pixels.
§Examples
artist.size(10.0);
Source

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

Sets the legend label for this scatter series.

When a label is set, the scatter series will appear in the legend if one is displayed on the axes. Pass an empty string or omit this call to exclude the series from the legend.

§Arguments
  • label - A string slice that will be stored as the legend entry.
§Examples
artist.label("Measurements");
Source

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

Sets the opacity (0.0 = fully transparent, 1.0 = fully opaque).

The value is clamped to the [0.0, 1.0] range. The default opacity is determined by the active theme (typically 0.8).

§Arguments
  • alpha - The desired opacity level.
§Examples
artist.alpha(0.5); // 50% transparent
Source

pub fn colors(&mut self, colors: Vec<Color>) -> &mut Self

Sets per-point colors, overriding the single uniform color.

When set, each data point is rendered with its corresponding color from the vector. The length of colors must equal the number of data points (x.len() and y.len()). This is commonly used to map a third variable to a colormap.

Calling color after this method does not clear the per-point colors; the per-point colors take precedence during rendering.

§Arguments
  • colors - A vector of Color values, one per data point.
§Examples
artist.colors(vec![Color::TAB_BLUE, Color::TAB_RED, Color::TAB_GREEN]);
Source

pub fn c(&mut self, c: Vec<f64>) -> &mut Self

Sets per-point scalar values for colormap-driven coloring.

When combined with cmap, each scalar value is mapped through the colormap to produce a per-point color. The length of c must equal the number of data points. This takes precedence over both the uniform color and colors.

§Arguments
  • c - A vector of scalar values, one per data point.
§Examples
artist.c(vec![0.0, 0.5, 1.0]).cmap(Colormap::Viridis);
Source

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

Sets the colormap used to map c values to colors.

Must be used together with c to have any effect. When both are set, the scatter plot renders each point with a color determined by mapping its c value through the given colormap.

§Arguments
§Examples
artist.c(values).cmap(Colormap::Plasma);

Trait Implementations§

Source§

impl Clone for ScatterArtist

Source§

fn clone(&self) -> ScatterArtist

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 ScatterArtist

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.