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>,
pub decimate: DecimateMode,
}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: SeriesX-coordinates of the data points.
y: SeriesY-coordinates of the data points.
color: ColorDefault marker color (used when colors is None).
marker: MarkerMarker shape.
size: f64Marker diameter in pixels.
label: Option<String>Optional legend label. When Some, the scatter appears in the legend.
alpha: f64Opacity 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.
decimate: DecimateModeControls how the series is downsampled before drawing.
Defaults to DecimateMode::Auto, which downsamples series larger than
DEFAULT_DECIMATE_THRESHOLD
using LTTB. Use the builder methods (.decimate, .decimate_with,
.no_decimate) to override.
Per-point styling (colors, c) is honored by re-indexing through the
selected indices, so decimation never desynchronizes colors from points.
Implementations§
Source§impl ScatterArtist
impl ScatterArtist
Source§impl ScatterArtist
impl ScatterArtist
Sourcepub fn label(&mut self, label: &str) -> &mut Self
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");Sourcepub fn colors(&mut self, colors: Vec<Color>) -> &mut Self
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 ofColorvalues, one per data point.
§Examples
artist.colors(vec![Color::TAB_BLUE, Color::TAB_RED, Color::TAB_GREEN]);Sourcepub fn c(&mut self, c: Vec<f64>) -> &mut Self
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);Sourcepub fn cmap(&mut self, cmap: Colormap) -> &mut Self
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
cmap- TheColormapvariant to use.
§Examples
artist.c(values).cmap(Colormap::Plasma);Sourcepub fn decimate(&mut self, threshold: usize) -> &mut Self
pub fn decimate(&mut self, threshold: usize) -> &mut Self
Enables LTTB decimation with the given explicit point threshold.
When the data series length exceeds threshold, the rendering pipeline
downsamples the points using the Largest Triangle Three Buckets
algorithm before drawing. Per-point styling (colors, c) stays
synchronized with the surviving points.
This overrides the default DecimateMode::Auto behavior with an
explicit threshold. To disable decimation entirely, use
no_decimate.
§Examples
ax.scatter(&x, &y)?.decimate(2000);Sourcepub fn decimate_with(
&mut self,
threshold: usize,
method: DecimateMethod,
) -> &mut Self
pub fn decimate_with( &mut self, threshold: usize, method: DecimateMethod, ) -> &mut Self
Enables decimation with a specific method and explicit point threshold.
Available methods:
DecimateMethod::Lttb— best visual fidelity (default)DecimateMethod::MinMax— fastest, preserves peaks/troughs
§Examples
ax.scatter(&x, &y)?.decimate_with(2000, DecimateMethod::MinMax);Sourcepub fn no_decimate(&mut self) -> &mut Self
pub fn no_decimate(&mut self) -> &mut Self
Disables decimation entirely, drawing every point.
By default large series are auto-decimated via DecimateMode::Auto.
Call this when every marker must be rendered regardless of series size.
§Examples
ax.scatter(&x, &y)?.no_decimate();Trait Implementations§
Source§impl Clone for ScatterArtist
impl Clone for ScatterArtist
Source§fn clone(&self) -> ScatterArtist
fn clone(&self) -> ScatterArtist
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more