pub struct ContourArtist {
pub x: Vec<f64>,
pub y: Vec<f64>,
pub z: Vec<Vec<f64>>,
pub levels: Option<Vec<f64>>,
pub filled: bool,
pub cmap: Colormap,
pub colors: Option<Vec<Color>>,
pub linewidths: f64,
pub label: Option<String>,
pub color: Color,
pub num_levels: usize,
}Expand description
A contour or filled contour plot over a 2D grid of z = f(x, y) values.
In unfilled mode (filled = false), iso-lines are drawn at each contour
level using the marching squares algorithm. In filled mode (filled = true),
the regions between contour levels are filled with colors from a colormap.
Fields§
§x: Vec<f64>X grid coordinates (length nx).
y: Vec<f64>Y grid coordinates (length ny).
z: Vec<Vec<f64>>Z values on the grid, shape [ny][nx] (row-major).
levels: Option<Vec<f64>>Explicit contour levels. When None, levels are auto-computed.
filled: boolWhether to fill regions between levels (true for contourf).
cmap: ColormapColormap used to map contour levels to colors.
colors: Option<Vec<Color>>Optional explicit colors for each contour level, overriding the colormap.
linewidths: f64Stroke width for contour lines (unfilled mode). Default 1.0.
label: Option<String>Optional legend label.
color: ColorPrimary color (used for legend swatch).
num_levels: usizeNumber of auto-computed levels when levels is None. Default 10.
Implementations§
Source§impl ContourArtist
impl ContourArtist
Source§impl ContourArtist
impl ContourArtist
Sourcepub fn colormap(&mut self, cmap: Colormap) -> &mut ContourArtist
pub fn colormap(&mut self, cmap: Colormap) -> &mut ContourArtist
Sets the colormap used to map contour levels to colors.
Sourcepub fn levels(&mut self, levels: Vec<f64>) -> &mut ContourArtist
pub fn levels(&mut self, levels: Vec<f64>) -> &mut ContourArtist
Sets explicit contour levels.
When None, levels are automatically computed by evenly spacing
between the minimum and maximum finite z values.
Sourcepub fn num_levels(&mut self, n: usize) -> &mut ContourArtist
pub fn num_levels(&mut self, n: usize) -> &mut ContourArtist
Sets the number of automatically computed contour levels.
Only used when explicit levels are not set. Defaults to 10.
Sourcepub fn linewidths(&mut self, w: f64) -> &mut ContourArtist
pub fn linewidths(&mut self, w: f64) -> &mut ContourArtist
Sets the line width for contour lines (unfilled mode).
Sourcepub fn colors(&mut self, colors: Vec<Color>) -> &mut ContourArtist
pub fn colors(&mut self, colors: Vec<Color>) -> &mut ContourArtist
Sets explicit colors for contour levels, overriding the colormap.
Sourcepub fn label(&mut self, label: &str) -> &mut ContourArtist
pub fn label(&mut self, label: &str) -> &mut ContourArtist
Sets the legend label.
Sourcepub fn effective_levels(&self) -> Vec<f64>
pub fn effective_levels(&self) -> Vec<f64>
Returns the effective contour levels.
If explicit levels are set, returns those. Otherwise, computes
num_levels evenly spaced levels between the minimum and maximum
finite z values.
Sourcepub fn z_bounds(&self) -> (f64, f64)
pub fn z_bounds(&self) -> (f64, f64)
Returns (zmin, zmax) from the finite z values.
Falls back to (0.0, 1.0) when the data contains no finite values.
Sourcepub fn marching_squares(&self, level: f64) -> Vec<(f64, f64, f64, f64)>
pub fn marching_squares(&self, level: f64) -> Vec<(f64, f64, f64, f64)>
Computes contour line segments for a single level using marching squares.
Returns a list of line segments, each represented as (x0, y0, x1, y1).
Sourcepub fn cell_averages(&self) -> Vec<Vec<f64>>
pub fn cell_averages(&self) -> Vec<Vec<f64>>
Computes the average z value for each grid cell.
Returns a 2D vector of shape [ny-1][nx-1] where each element is the
mean of the four corner z values. Used for the simplified filled
contour approach.
Trait Implementations§
Source§impl Clone for ContourArtist
impl Clone for ContourArtist
Source§fn clone(&self) -> ContourArtist
fn clone(&self) -> ContourArtist
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ContourArtist
impl RefUnwindSafe for ContourArtist
impl Send for ContourArtist
impl Sync for ContourArtist
impl Unpin for ContourArtist
impl UnsafeUnpin for ContourArtist
impl UnwindSafe for ContourArtist
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more