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

Function test_gridspec_1

tests/test_subplot.rs:54–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52
53#[test]
54fn test_gridspec_1() -> Result<(), StrError> {
55 // curves
56 let mut curve1 = Curve::new();
57 let mut curve2 = Curve::new();
58 let x = &[1.0, 2.0, 3.0, 4.0];
59 let y = &[1.0, 1.424, 1.732, 2.0];
60 let z = &[1.0, 4.0, 9.0, 16.0];
61 curve1.draw(x, y);
62 curve2.draw(x, z);
63
64 // plot and gridspec
65 let mut plot = Plot::new();
66 plot.set_gridspec("my_grid", 3, 1, "wspace=0, hspace=0.7")
67 .set_subplot_grid("my_grid", "0:2", "0")
68 .add(&curve1)
69 .set_subplot_grid("my_grid", "2", "0")
70 .add(&curve2);
71
72 // save figure
73 let path = Path::new(OUT_DIR).join("integ_gridspec_1.svg");
74 plot.save(&path)?;
75
76 // check number of lines
77 let file = File::open(path).map_err(|_| "cannot open file")?;
78 let buffered = BufReader::new(file);
79 let lines_iter = buffered.lines();
80 let n = lines_iter.count();
81 assert!(n > 650);
82 assert!(n < 700);
83 Ok(())
84}
85
86#[test]
87fn test_gridspec_rotation_and_align_labels() -> Result<(), StrError> {

Callers

nothing calls this directly

Calls 5

set_subplot_gridMethod · 0.80
set_gridspecMethod · 0.80
saveMethod · 0.80
drawMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected