MCPcopy Create free account
hub / github.com/cpmech/plotpy / test_subplot_3d

Function test_subplot_3d

tests/test_subplot_3d.rs:9–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8#[test]
9fn test_subplot_3d() -> Result<(), StrError> {
10 // data
11 let n = 9;
12 let (x, y, z) = generate3d(-2.0, 2.0, -2.0, 2.0, n, n, |x, y| x * x + y * y);
13
14 // plot
15 let mut plot = Plot::new();
16
17 // surfaces
18 let mut surf1 = Surface::new();
19 let mut surf2 = Surface::new();
20 let mut surf3 = Surface::new();
21 let mut surf4 = Surface::new();
22 surf1.set_colormap_name("terrain").draw(&x, &y, &z);
23 surf2.set_with_surface(false).set_with_wireframe(true).draw(&x, &y, &z);
24 surf3.set_surf_color("gold").draw(&x, &y, &z);
25 surf4
26 .set_with_surface(false)
27 .set_with_wireframe(true)
28 .set_with_points(true)
29 .set_wire_line_color("lime")
30 .set_wire_line_width(1.5)
31 .set_point_color("black")
32 .set_point_void(true)
33 .set_point_size(30.0)
34 .draw(&x, &y, &z);
35
36 // add surfaces to plot
37 plot.set_subplot_3d(2, 2, 1)
38 .set_label_x("X AXIS IS BEAUTIFUL")
39 .set_label_y("Y AXIS IS BEAUTIFUL")
40 .set_label_z("Z AXIS IS BEAUTIFUL")
41 .add(&surf1);
42 plot.set_subplot_3d(2, 2, 2)
43 .set_labels_3d("X AXIS IS BEAUTIFUL", "Y AXIS IS BEAUTIFUL", "Z AXIS IS BEAUTIFUL")
44 .add(&surf2);
45 plot.set_subplot_3d(2, 2, 3)
46 .set_labels_3d("X AXIS IS BEAUTIFUL", "Y AXIS IS BEAUTIFUL", "Z AXIS IS BEAUTIFUL")
47 .add(&surf3);
48 plot.set_subplot_3d(2, 2, 4)
49 .set_labels_3d("X AXIS IS BEAUTIFUL", "Y AXIS IS BEAUTIFUL", "Z AXIS IS BEAUTIFUL")
50 .add(&surf4);
51
52 // save figure
53 let path = Path::new(OUT_DIR).join("integ_subplot_3d.svg");
54 plot.set_figure_size_points(600.0, 600.0)
55 .set_save_pad_inches(0.4)
56 .save(&path)?;
57
58 // check number of lines
59 let file = File::open(path).map_err(|_| "cannot open file")?;
60 let buffered = BufReader::new(file);
61 let lines_iter = buffered.lines();
62 let n_lines = lines_iter.count();
63 assert!(n_lines > 3300 && n < 3400);
64 Ok(())
65}

Callers

nothing calls this directly

Calls 15

generate3dFunction · 0.85
set_with_wireframeMethod · 0.80
set_with_surfaceMethod · 0.80
set_surf_colorMethod · 0.80
set_point_sizeMethod · 0.80
set_point_voidMethod · 0.80
set_point_colorMethod · 0.80
set_wire_line_widthMethod · 0.80
set_wire_line_colorMethod · 0.80
set_with_pointsMethod · 0.80
set_label_zMethod · 0.80
set_label_yMethod · 0.80

Tested by

no test coverage detected