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

Function test_gridspec_rotation_and_align_labels

tests/test_subplot.rs:87–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85
86#[test]
87fn test_gridspec_rotation_and_align_labels() -> Result<(), StrError> {
88 // curves
89 let mut curve = Curve::new();
90 let x = &[1000.0, 2000.0, 3000.0, 4000.0];
91 let y = &[1.0, 2.0, 3.0, 4.0];
92 curve.draw(x, y);
93
94 // plot and gridspec
95 let mut plot = Plot::new();
96 plot.set_gridspec("grid", 2, 2, "hspace=0.35")
97 .set_subplot_grid("grid", "0", ":")
98 .set_label_x("x-label 0 0")
99 .set_label_y("y-label 0 0")
100 .set_rotation_ticks_y(55.0)
101 .add(&curve)
102 .set_subplot_grid("grid", "1", "0")
103 .set_label_x("x-label 1 0")
104 .set_label_y("y-label 1 0")
105 .set_rotation_ticks_x(55.0)
106 .add(&curve)
107 .set_subplot_grid("grid", "1", "1")
108 .set_label_x("x-label 1 1")
109 .set_label_y("y-label 1 1")
110 .add(&curve)
111 .set_align_labels();
112
113 // save figure
114 let path = Path::new(OUT_DIR).join("integ_gridspec_2.svg");
115 plot.save(&path)?;
116
117 // check number of lines
118 let file = File::open(path).map_err(|_| "cannot open file")?;
119 let buffered = BufReader::new(file);
120 let lines_iter = buffered.lines();
121 let n = lines_iter.count();
122 assert!(n > 930);
123 assert!(n < 960);
124 Ok(())
125}

Callers

nothing calls this directly

Calls 10

set_align_labelsMethod · 0.80
set_label_yMethod · 0.80
set_label_xMethod · 0.80
set_subplot_gridMethod · 0.80
set_rotation_ticks_xMethod · 0.80
set_rotation_ticks_yMethod · 0.80
set_gridspecMethod · 0.80
saveMethod · 0.80
drawMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected