pub struct Mesh3D { /* private fields */ }Expand description
A structure representing a 3D mesh plot.
The Mesh3D struct is designed to create and customize 3D mesh visualizations
with support for explicit triangulation, intensity-based coloring, and various
lighting effects. It can handle both auto-triangulated point clouds and
explicitly defined mesh connectivity through triangle indices.
§Backend Support
| Backend | Supported |
|---|---|
| Plotly | Yes |
| Plotters | – |
§Arguments
data- A reference to theDataFramecontaining the mesh data.x- A string slice specifying the column name for x-axis vertex coordinates.y- A string slice specifying the column name for y-axis vertex coordinates.z- A string slice specifying the column name for z-axis vertex coordinates.i- An optional string slice specifying the column name for first vertex indices of triangles.j- An optional string slice specifying the column name for second vertex indices of triangles.k- An optional string slice specifying the column name for third vertex indices of triangles.intensity- An optional string slice specifying the column name for intensity values used in gradient coloring.intensity_mode- An optionalIntensityModespecifying whether intensity applies to vertices or cells.color- An optionalRgbvalue for uniform mesh coloring.color_bar- An optional reference to aColorBarfor customizing the color legend.color_scale- An optionalPalettedefining the color gradient for intensity mapping.reverse_scale- An optional boolean to reverse the color scale direction.show_scale- An optional boolean to show/hide the color bar.opacity- An optionalf64value specifying mesh transparency (range: 0.0 to 1.0).flat_shading- An optional boolean for angular (true) vs smooth (false) shading.lighting- An optional reference to aLightingstruct for custom lighting settings.light_position- An optional tuple(x, y, z)specifying the light source position.delaunay_axis- An optional string specifying the axis for Delaunay triangulation (“x”, “y”, or “z”).contour- An optional boolean to enable contour lines on the mesh.facet- An optional string slice specifying the column name to be used for faceting (creating multiple subplots).facet_config- An optional reference to aFacetConfigstruct for customizing facet behavior (grid dimensions, scales, gaps, etc.).plot_title- An optionalTextstruct specifying the plot title.x_title- An optionalTextstruct for the x-axis title.y_title- An optionalTextstruct for the y-axis title.z_title- An optionalTextstruct for the z-axis title.legend- An optional reference to aLegendstruct for legend customization.
§Example
use plotlars::{Lighting, Mesh3D, Plot, Rgb, Text};
use polars::prelude::*;
let mut x = Vec::new();
let mut y = Vec::new();
let mut z = Vec::new();
let n = 20;
for i in 0..n {
for j in 0..n {
let xi = (i as f64 / (n - 1) as f64) * 2.0 - 1.0;
let yj = (j as f64 / (n - 1) as f64) * 2.0 - 1.0;
x.push(xi);
y.push(yj);
z.push(0.3 * ((xi * 3.0).sin() + (yj * 3.0).cos()));
}
}
let dataset = DataFrame::new(x.len(), vec![
Column::new("x".into(), x),
Column::new("y".into(), y),
Column::new("z".into(), z),
])
.unwrap();
Mesh3D::builder()
.data(&dataset)
.x("x")
.y("y")
.z("z")
.color(Rgb(200, 200, 255))
.lighting(
&Lighting::new()
.ambient(0.5)
.diffuse(0.8)
.specular(0.5)
.roughness(0.2)
.fresnel(0.2),
)
.light_position((1, 1, 2))
.opacity(1.0)
.flat_shading(false)
.contour(true)
.plot_title(
Text::from("Mesh 3D Plot")
.font("Arial")
.size(22),
)
.build()
.plot();
Implementations§
Source§impl Mesh3D
impl Mesh3D
pub fn builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8, 'f9, 'f10, 'f11, 'f12, 'f13, 'f14>() -> Mesh3DBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8, 'f9, 'f10, 'f11, 'f12, 'f13, 'f14>
Source§impl Mesh3D
impl Mesh3D
pub fn try_new( data: &DataFrame, x: &str, y: &str, z: &str, i: Option<&str>, j: Option<&str>, k: Option<&str>, intensity: Option<&str>, intensity_mode: Option<IntensityMode>, color: Option<Rgb>, color_bar: Option<&ColorBar>, color_scale: Option<Palette>, _reverse_scale: Option<bool>, _show_scale: Option<bool>, opacity: Option<f64>, flat_shading: Option<bool>, lighting: Option<&Lighting>, light_position: Option<(i32, i32, i32)>, delaunay_axis: Option<&str>, contour: Option<bool>, facet: Option<&str>, facet_config: Option<&FacetConfig>, plot_title: Option<Text>, x_title: Option<Text>, y_title: Option<Text>, z_title: Option<Text>, legend: Option<&Legend>, ) -> Result<Self, PlotlarsError>
pub fn try_builder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8, 'f9, 'f10, 'f11, 'f12, 'f13, 'f14>() -> Mesh3DTryBuilder<'f1, 'f2, 'f3, 'f4, 'f5, 'f6, 'f7, 'f8, 'f9, 'f10, 'f11, 'f12, 'f13, 'f14>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mesh3D
impl RefUnwindSafe for Mesh3D
impl Send for Mesh3D
impl Sync for Mesh3D
impl Unpin for Mesh3D
impl UnsafeUnpin for Mesh3D
impl UnwindSafe for Mesh3D
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