pub struct ContourOpts { /* private fields */ }Implementations§
Source§impl ContourOpts
impl ContourOpts
Sourcepub fn x_edges(self, e: Vec<f64>) -> Self
pub fn x_edges(self, e: Vec<f64>) -> Self
Examples found in repository?
examples/gen_hero_svgs.rs (line 228)
206fn contour() -> String {
207 let n = 41;
208 let pi = std::f64::consts::PI;
209 let grid: Vec<Vec<f64>> = (0..n)
210 .map(|j| {
211 let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
212 (0..n)
213 .map(|i| {
214 let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
215 x.sin() * y.cos()
216 })
217 .collect()
218 })
219 .collect();
220 let edges: Vec<f64> = (0..=n).map(|i| -pi + 2.0 * pi * i as f64 / n as f64).collect();
221
222 Figure::new()
223 .size(PaperSize::Square)
224 .title("sin(x) · cos(y)")
225 .xlabel("x")
226 .ylabel("y")
227 .contour(grid, |c| {
228 c.x_edges(edges.clone())
229 .y_edges(edges.clone())
230 .levels(vec![-0.8, -0.4, 0.0, 0.4, 0.8])
231 })
232 .to_svg()
233}More examples
examples/contour.rs (line 31)
3fn main() {
4 // 41×41 grid of sin(x) · cos(y) over [-π, π]².
5 let n = 41;
6 let pi = std::f64::consts::PI;
7 let grid: Vec<Vec<f64>> = (0..n)
8 .map(|j| {
9 let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
10 (0..n)
11 .map(|i| {
12 let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
13 x.sin() * y.cos()
14 })
15 .collect()
16 })
17 .collect();
18
19 let edges: Vec<f64> = (0..=n)
20 .map(|i| -pi + 2.0 * pi * i as f64 / n as f64)
21 .collect();
22
23 let levels = vec![-0.8, -0.4, 0.0, 0.4, 0.8];
24
25 let fig = Figure::new()
26 .size(PaperSize::Square)
27 .title("sin(x) · cos(y)")
28 .xlabel("x")
29 .ylabel("y")
30 .contour(grid, |c| {
31 c.x_edges(edges.clone())
32 .y_edges(edges.clone())
33 .levels(levels)
34 .label("isolines")
35 })
36 .legend_top_right();
37
38 std::fs::create_dir_all("out").expect("create out/");
39 std::fs::write("out/contour.svg", fig.to_svg()).expect("write svg");
40 println!("wrote out/contour.svg");
41}Sourcepub fn y_edges(self, e: Vec<f64>) -> Self
pub fn y_edges(self, e: Vec<f64>) -> Self
Examples found in repository?
examples/gen_hero_svgs.rs (line 229)
206fn contour() -> String {
207 let n = 41;
208 let pi = std::f64::consts::PI;
209 let grid: Vec<Vec<f64>> = (0..n)
210 .map(|j| {
211 let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
212 (0..n)
213 .map(|i| {
214 let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
215 x.sin() * y.cos()
216 })
217 .collect()
218 })
219 .collect();
220 let edges: Vec<f64> = (0..=n).map(|i| -pi + 2.0 * pi * i as f64 / n as f64).collect();
221
222 Figure::new()
223 .size(PaperSize::Square)
224 .title("sin(x) · cos(y)")
225 .xlabel("x")
226 .ylabel("y")
227 .contour(grid, |c| {
228 c.x_edges(edges.clone())
229 .y_edges(edges.clone())
230 .levels(vec![-0.8, -0.4, 0.0, 0.4, 0.8])
231 })
232 .to_svg()
233}More examples
examples/contour.rs (line 32)
3fn main() {
4 // 41×41 grid of sin(x) · cos(y) over [-π, π]².
5 let n = 41;
6 let pi = std::f64::consts::PI;
7 let grid: Vec<Vec<f64>> = (0..n)
8 .map(|j| {
9 let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
10 (0..n)
11 .map(|i| {
12 let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
13 x.sin() * y.cos()
14 })
15 .collect()
16 })
17 .collect();
18
19 let edges: Vec<f64> = (0..=n)
20 .map(|i| -pi + 2.0 * pi * i as f64 / n as f64)
21 .collect();
22
23 let levels = vec![-0.8, -0.4, 0.0, 0.4, 0.8];
24
25 let fig = Figure::new()
26 .size(PaperSize::Square)
27 .title("sin(x) · cos(y)")
28 .xlabel("x")
29 .ylabel("y")
30 .contour(grid, |c| {
31 c.x_edges(edges.clone())
32 .y_edges(edges.clone())
33 .levels(levels)
34 .label("isolines")
35 })
36 .legend_top_right();
37
38 std::fs::create_dir_all("out").expect("create out/");
39 std::fs::write("out/contour.svg", fig.to_svg()).expect("write svg");
40 println!("wrote out/contour.svg");
41}Sourcepub fn levels(self, l: Vec<f64>) -> Self
pub fn levels(self, l: Vec<f64>) -> Self
Examples found in repository?
examples/gen_hero_svgs.rs (line 230)
206fn contour() -> String {
207 let n = 41;
208 let pi = std::f64::consts::PI;
209 let grid: Vec<Vec<f64>> = (0..n)
210 .map(|j| {
211 let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
212 (0..n)
213 .map(|i| {
214 let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
215 x.sin() * y.cos()
216 })
217 .collect()
218 })
219 .collect();
220 let edges: Vec<f64> = (0..=n).map(|i| -pi + 2.0 * pi * i as f64 / n as f64).collect();
221
222 Figure::new()
223 .size(PaperSize::Square)
224 .title("sin(x) · cos(y)")
225 .xlabel("x")
226 .ylabel("y")
227 .contour(grid, |c| {
228 c.x_edges(edges.clone())
229 .y_edges(edges.clone())
230 .levels(vec![-0.8, -0.4, 0.0, 0.4, 0.8])
231 })
232 .to_svg()
233}More examples
examples/contour.rs (line 33)
3fn main() {
4 // 41×41 grid of sin(x) · cos(y) over [-π, π]².
5 let n = 41;
6 let pi = std::f64::consts::PI;
7 let grid: Vec<Vec<f64>> = (0..n)
8 .map(|j| {
9 let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
10 (0..n)
11 .map(|i| {
12 let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
13 x.sin() * y.cos()
14 })
15 .collect()
16 })
17 .collect();
18
19 let edges: Vec<f64> = (0..=n)
20 .map(|i| -pi + 2.0 * pi * i as f64 / n as f64)
21 .collect();
22
23 let levels = vec![-0.8, -0.4, 0.0, 0.4, 0.8];
24
25 let fig = Figure::new()
26 .size(PaperSize::Square)
27 .title("sin(x) · cos(y)")
28 .xlabel("x")
29 .ylabel("y")
30 .contour(grid, |c| {
31 c.x_edges(edges.clone())
32 .y_edges(edges.clone())
33 .levels(levels)
34 .label("isolines")
35 })
36 .legend_top_right();
37
38 std::fs::create_dir_all("out").expect("create out/");
39 std::fs::write("out/contour.svg", fig.to_svg()).expect("write svg");
40 println!("wrote out/contour.svg");
41}pub fn origin(self, o: Origin) -> Self
pub fn stroke(self, s: Stroke) -> Self
pub fn stroke_width(self, w: f64) -> Self
Sourcepub fn label(self, s: impl Into<String>) -> Self
pub fn label(self, s: impl Into<String>) -> Self
Examples found in repository?
examples/contour.rs (line 34)
3fn main() {
4 // 41×41 grid of sin(x) · cos(y) over [-π, π]².
5 let n = 41;
6 let pi = std::f64::consts::PI;
7 let grid: Vec<Vec<f64>> = (0..n)
8 .map(|j| {
9 let y = -pi + 2.0 * pi * j as f64 / (n - 1) as f64;
10 (0..n)
11 .map(|i| {
12 let x = -pi + 2.0 * pi * i as f64 / (n - 1) as f64;
13 x.sin() * y.cos()
14 })
15 .collect()
16 })
17 .collect();
18
19 let edges: Vec<f64> = (0..=n)
20 .map(|i| -pi + 2.0 * pi * i as f64 / n as f64)
21 .collect();
22
23 let levels = vec![-0.8, -0.4, 0.0, 0.4, 0.8];
24
25 let fig = Figure::new()
26 .size(PaperSize::Square)
27 .title("sin(x) · cos(y)")
28 .xlabel("x")
29 .ylabel("y")
30 .contour(grid, |c| {
31 c.x_edges(edges.clone())
32 .y_edges(edges.clone())
33 .levels(levels)
34 .label("isolines")
35 })
36 .legend_top_right();
37
38 std::fs::create_dir_all("out").expect("create out/");
39 std::fs::write("out/contour.svg", fig.to_svg()).expect("write svg");
40 println!("wrote out/contour.svg");
41}Trait Implementations§
Source§impl Debug for ContourOpts
impl Debug for ContourOpts
Auto Trait Implementations§
impl Freeze for ContourOpts
impl RefUnwindSafe for ContourOpts
impl Send for ContourOpts
impl Sync for ContourOpts
impl Unpin for ContourOpts
impl UnsafeUnpin for ContourOpts
impl UnwindSafe for ContourOpts
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