Skip to main content

LineArtist

Struct LineArtist 

Source
pub struct LineArtist {
    pub x: Series,
    pub y: Series,
    pub color: Color,
    pub width: f64,
    pub style: LineStyle,
    pub label: Option<String>,
    pub alpha: f64,
    pub decimate: Option<(usize, DecimateMethod)>,
}
Expand description

A line chart connecting a sequence of (x, y) data points.

The x and y series must have the same length. Points are drawn in order, producing a single connected polyline with the configured stroke style.

Fields§

§x: Series

X-coordinates of the data points.

§y: Series

Y-coordinates of the data points.

§color: Color

Stroke color of the line.

§width: f64

Stroke width in pixels.

§style: LineStyle

Stroke pattern (solid, dashed, dotted, dash-dot).

§label: Option<String>

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

§alpha: f64

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

§decimate: Option<(usize, DecimateMethod)>

Optional decimation: (threshold, method). When set and data length exceeds threshold, the rendering pipeline downsamples the data before drawing.

Implementations§

Source§

impl LineArtist

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 LineArtist

Source

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

Sets the line color.

Accepts any Color value, which can be constructed from RGB components, hex strings, or named color constants.

§Examples
artist.color(Color::rgb(1.0, 0.0, 0.0)); // red
Source

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

Sets the line width in pixels.

A width of 1.0 is the default hairline width. Values below 1.0 may produce sub-pixel rendering depending on the backend.

§Examples
artist.width(2.5);
Source

pub fn style(&mut self, style: LineStyle) -> &mut Self

Sets the line style (solid, dashed, dotted, dash-dot).

The LineStyle enum defines the available stroke patterns. The default is LineStyle::Solid.

§Examples
artist.style(LineStyle::Dashed);
Source

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

Sets the legend label for this line.

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

§Examples
artist.label("Temperature");
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 1.0.

§Examples
artist.alpha(0.5); // 50% transparent
Source

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

Enables LTTB decimation with the given point threshold.

When the data series length exceeds threshold, the rendering pipeline downsamples the data using the Largest Triangle Three Buckets algorithm before drawing. This dramatically improves rendering performance for large datasets (100k+ points) with negligible visual impact.

§Examples
ax.plot(&x, &y)?.decimate(1000);
Source

pub fn decimate_with( &mut self, threshold: usize, method: DecimateMethod, ) -> &mut Self

Enables decimation with a specific method and point threshold.

Available methods:

§Examples
ax.plot(&x, &y)?.decimate_with(1000, DecimateMethod::MinMax);

Trait Implementations§

Source§

impl Clone for LineArtist

Source§

fn clone(&self) -> LineArtist

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 LineArtist

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.