pub struct GeomSmooth {
pub color: (u8, u8, u8),
pub fill: (u8, u8, u8),
pub line_width: f64,
pub alpha: f64,
pub se: bool,
pub n_points: usize,
pub method: SmoothMethod,
}Expand description
Smooth line with optional confidence ribbon.
Fields§
§color: (u8, u8, u8)§fill: (u8, u8, u8)§line_width: f64§alpha: f64§se: bool§n_points: usize§method: SmoothMethodImplementations§
Source§impl GeomSmooth
impl GeomSmooth
Sourcepub fn loess(self, span: f64) -> Self
pub fn loess(self, span: f64) -> Self
Use LOESS smoothing with the given span.
Examples found in repository?
examples/loess_smooth.rs (line 34)
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 // Generate noisy sine wave data
6 let x: Vec<f64> = (0..80).map(|i| (i as f64) * 0.1).collect();
7 let y: Vec<f64> = (0..80)
8 .map(|i| {
9 let xv = (i as f64) * 0.1;
10 let noise = ((i * 17 + 3) % 11) as f64 / 11.0 - 0.5; // deterministic pseudo-noise
11 (xv * 0.8).sin() * 2.0 + noise * 1.5
12 })
13 .collect();
14
15 let df = df! {
16 "x" => &x,
17 "y" => &y,
18 }?;
19
20 // Linear smooth (default)
21 GGPlot::new(df.clone())
22 .aes(Aes::new().x("x").y("y"))
23 .geom_point()
24 .geom_smooth()
25 .title("Linear Smooth (method = lm)")
26 .save("smooth_lm.svg")?;
27
28 println!("Saved smooth_lm.svg");
29
30 // LOESS smooth
31 GGPlot::new(df)
32 .aes(Aes::new().x("x").y("y"))
33 .geom_point()
34 .geom_smooth_with(GeomSmooth::default().loess(0.3))
35 .title("LOESS Smooth (span = 0.3)")
36 .save("smooth_loess.svg")?;
37
38 println!("Saved smooth_loess.svg");
39 Ok(())
40}Trait Implementations§
Source§impl Default for GeomSmooth
impl Default for GeomSmooth
Source§impl Geom for GeomSmooth
impl Geom for GeomSmooth
Source§fn draw(
&self,
data: &DataFrame,
coord: &dyn Coord,
scales: &ScaleSet,
_theme: &Theme,
backend: &mut dyn DrawBackend,
) -> Result<(), RenderError>
fn draw( &self, data: &DataFrame, coord: &dyn Coord, scales: &ScaleSet, _theme: &Theme, backend: &mut dyn DrawBackend, ) -> Result<(), RenderError>
Draw this geometry.
Source§fn required_aes(&self) -> Vec<Aesthetic>
fn required_aes(&self) -> Vec<Aesthetic>
Required aesthetics.
Source§fn default_stat(&self) -> Box<dyn Stat>
fn default_stat(&self) -> Box<dyn Stat>
Default stat for this geom.
Source§fn default_position(&self) -> Box<dyn Position>
fn default_position(&self) -> Box<dyn Position>
Default position adjustment.
Source§fn default_params(&self) -> GeomParams
fn default_params(&self) -> GeomParams
Non-mapped visual defaults.
Source§fn set_series_color(&mut self, color: (u8, u8, u8))
fn set_series_color(&mut self, color: (u8, u8, u8))
Apply a brand/primary color to this geom’s single-series default (its
color or fill). The build pipeline calls this only when the layer has
no color/fill aesthetic mapped, so an explicit mapping always wins. The
default is a no-op; series geoms override it.Auto Trait Implementations§
impl Freeze for GeomSmooth
impl RefUnwindSafe for GeomSmooth
impl Send for GeomSmooth
impl Sync for GeomSmooth
impl Unpin for GeomSmooth
impl UnsafeUnpin for GeomSmooth
impl UnwindSafe for GeomSmooth
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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