Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/contour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use std::fmt::Write;
///
/// ![integ_contour.svg](https://raw.githubusercontent.com/cpmech/plotpy/main/figures/integ_contour.svg)
pub struct Contour {
alpha: f64, // Alpha (transparacy) of the plot
colors: Vec<String>, // Colors to be used instead of colormap
levels: Vec<f64>, // Pre-defined levels
colormap_name: String, // Colormap name
Expand Down Expand Up @@ -83,6 +84,7 @@ impl Contour {
/// Creates a new Contour object
pub fn new() -> Self {
Contour {
alpha: 1.0,
colors: Vec::new(),
levels: Vec::new(),
colormap_name: "bwr".to_string(),
Expand Down Expand Up @@ -223,6 +225,12 @@ impl Contour {
}
}

/// Sets the alpha value to alpha instead of the pre-defined alpha
pub fn set_alpha(&mut self, alpha: f64) -> &mut Self {
self.alpha = alpha;
self
}

/// Sets the colors to be used instead of a pre-defined colormap
///
/// Will use `colormap_index` instead if its empty.
Expand Down Expand Up @@ -474,6 +482,7 @@ impl Contour {
if self.extra_filled != "" {
write!(&mut opt, ",{}", self.extra_filled).unwrap();
}
write!(&mut opt, ",alpha={}", self.alpha).unwrap();
opt
}

Expand Down Expand Up @@ -695,4 +704,4 @@ mod tests {
contour.clear_buffer();
assert_eq!(contour.buffer, "");
}
}
}
Loading