Usage Modes
Standalone — create withBandPlot::new and add as Plot::Band. Pair with a Plot::Line or Plot::Scatter in the same plots vector to draw the band behind the data series.
Attached — use LinePlot::with_band or ScatterPlot::with_band as a one-call shorthand. The band inherits the series color automatically and is rendered behind the line or points.
Constructor
new()
Create a band from parallel x, lower-bound, and upper-bound iterables.
X coordinates shared by both boundary curves
Lower boundary y values. Must have the same length as
xUpper boundary y values. Must have the same length as
xBandPlot
All three iterables must have the same length. Accepts any type implementing Into<f64>. Default fill: "steelblue" at opacity 0.2.
Styling
with_color()
Set the fill color.
CSS color string (default:
"steelblue")Self
Accepts any CSS color string. When using the standalone mode, set this to match the paired line or scatter color for a cohesive look.
with_opacity()
Set the fill opacity.
Fill opacity in
[0.0, 1.0] (default: 0.2)Self
Lower values make the band more transparent; 1.0 gives a fully opaque filled area.
Legend
with_legend()
Enable a legend entry with the given label.
Legend label text
Self
The legend swatch is a filled rectangle in the band color.
Complete Example
Public Fields
X coordinates shared by both boundary curves
Lower boundary y values. Must have the same length as
xUpper boundary y values. Must have the same length as
xFill color as a CSS color string. Default:
"steelblue"Fill opacity in
[0.0, 1.0]. Default: 0.2When
Some, a legend entry is shown with a filled rectangle swatch