pub struct ContourPlot { /* private fields */ }Expand description
A structure representing a contour plot.
The ContourPlot struct enables the creation of contour visualizations that display level
curves of a three‑dimensional surface on a two‑dimensional plane. It offers extensive
configuration options for contour styling, color scaling, axis appearance, legends, and
annotations. Users can fine‑tune the contour interval, choose from predefined color palettes,
reverse or hide the color scale, and set custom titles for both the plot and its axes in
order to improve the readability of complex surfaces.
§Arguments
data- A reference to theDataFramecontaining the data to be plotted.x- A string slice specifying the column name for x‑axis values.y- A string slice specifying the column name for y‑axis values.z- A string slice specifying the column name for z‑axis values whose magnitude determines each contour line.color_bar- An optional reference to aColorBarstruct for customizing the color bar appearance.color_scale- An optionalPaletteenum for specifying the color palette (e.g.,Palette::Viridis).reverse_scale- An optional boolean to reverse the color scale direction.show_scale- An optional boolean to display the color scale on the plot.contours- An optional reference to aContoursstruct for configuring the contour interval, size, and coloring.plot_title- An optionalTextstruct for setting the title of the plot.x_title- An optionalTextstruct for labeling the x‑axis.y_title- An optionalTextstruct for labeling the y‑axis.x_axis- An optional reference to anAxisstruct for customizing x‑axis appearance.y_axis- An optional reference to anAxisstruct for customizing y‑axis appearance.
§Example
use polars::prelude::*;
use plotlars::{Plot, Coloring, ContourPlot, Palette, Text};
let dataset = df!(
"x" => &[0.0, 0.0, 0.0, 2.5, 2.5, 2.5, 5.0, 5.0, 5.0],
"y" => &[0.0, 7.5, 15.0, 0.0, 7.5, 15.0, 0.0, 7.5, 15.0],
"z" => &[0.0, 5.0, 10.0, 5.0, 2.5, 5.0, 10.0, 0.0, 0.0],
)
.unwrap();
ContourPlot::builder()
.data(&dataset)
.x("x")
.y("y")
.z("z")
.color_scale(Palette::Viridis)
.reverse_scale(true)
.coloring(Coloring::Fill)
.show_lines(false)
.plot_title(
Text::from("Contour Plot")
.font("Arial")
.size(18)
)
.build()
.plot();
Implementations§
Source§impl ContourPlot
impl ContourPlot
Sourcepub fn builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>() -> ContourPlotBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>
pub fn builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>() -> ContourPlotBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7>
Examples found in repository?
examples/contourplot.rs (line 13)
5fn main() {
6 let dataset = df!(
7 "x" => &[0.0, 0.0, 0.0, 2.5, 2.5, 2.5, 5.0, 5.0, 5.0],
8 "y" => &[0.0, 7.5, 15.0, 0.0, 7.5, 15.0, 0.0, 7.5, 15.0],
9 "z" => &[0.0, 5.0, 10.0, 5.0, 2.5, 5.0, 10.0, 0.0, 0.0],
10 )
11 .unwrap();
12
13 ContourPlot::builder()
14 .data(&dataset)
15 .x("x")
16 .y("y")
17 .z("z")
18 .color_scale(Palette::Viridis)
19 .reverse_scale(true)
20 .coloring(Coloring::Fill)
21 .show_lines(false)
22 .plot_title(Text::from("Contour Plot").font("Arial").size(18))
23 .build()
24 .plot();
25}Trait Implementations§
Source§impl Clone for ContourPlot
impl Clone for ContourPlot
Source§fn clone(&self) -> ContourPlot
fn clone(&self) -> ContourPlot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ContourPlot
impl !RefUnwindSafe for ContourPlot
impl !Send for ContourPlot
impl !Sync for ContourPlot
impl Unpin for ContourPlot
impl !UnwindSafe for ContourPlot
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
Converts
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> ⓘ
Converts
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