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

Function test_plot_3d

tests/test_plot.rs:101–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99
100#[test]
101fn test_plot_3d() -> Result<(), StrError> {
102 // curve
103 let curve = gen_curve_3d();
104
105 // plot
106 let mut plot = Plot::new();
107 plot.set_subplot_3d(2, 2, 1)
108 .add(&curve)
109 .set_labels_3d("X AXIS", "Y AXIS", "Z AXIS")
110 .set_num_ticks_x(0)
111 .set_num_ticks_y(0)
112 .set_num_ticks_z(0)
113 .set_subplot_3d(2, 2, 2)
114 .add(&curve)
115 .set_label_x("X AXIS IS BEAUTIFUL")
116 .set_label_y("Y AXIS IS BEAUTIFUL")
117 .set_label_z("Z AXIS IS BEAUTIFUL")
118 .set_xrange(-3.0, 3.0)
119 .set_yrange(-3.0, 3.0)
120 .set_zrange(-1.5, 1.5)
121 .set_num_ticks_x(3)
122 .set_num_ticks_y(3)
123 .set_num_ticks_z(3)
124 .set_hide_xticks()
125 .set_hide_yticks()
126 .set_hide_zticks()
127 .set_subplot_3d(2, 2, 3)
128 .add(&curve)
129 .set_labels_3d("X HERE", "Y HERE", "Z HERE")
130 .set_xmin(-2.0)
131 .set_xmax(2.0)
132 .set_ymin(-2.0)
133 .set_ymax(2.0)
134 .set_zmin(-1.0)
135 .set_zmax(1.0)
136 .set_subplot_3d(2, 2, 4)
137 .add(&curve)
138 .set_hide_xticks()
139 .set_hide_yticks()
140 .set_hide_zticks()
141 .set_label_x_and_pad("X IS CLOSER NOW", -15.0)
142 .set_label_y_and_pad("Y IS CLOSER NOW", -15.0)
143 .set_label_z_and_pad("Z IS CLOSER NOW", -15.0)
144 .set_range_3d(-10.0, 10.0, -10.0, 10.0, -3.0, 3.0);
145
146 // save figure
147 let path = Path::new(OUT_DIR).join("integ_plot_3d.svg");
148 plot.set_horizontal_gap(0.2)
149 .set_save_pad_inches(0.4)
150 .set_figure_size_points(600.0, 600.0)
151 .save(&path)?;
152
153 // check number of lines
154 let file = File::open(path).map_err(|_| "cannot open file")?;
155 let buffered = BufReader::new(file);
156 let lines_iter = buffered.lines();
157 let n_lines = lines_iter.count();
158 assert!(n_lines > 1800 && n_lines < 1950);

Callers

nothing calls this directly

Calls 15

gen_curve_3dFunction · 0.85
set_range_3dMethod · 0.80
set_label_z_and_padMethod · 0.80
set_label_y_and_padMethod · 0.80
set_label_x_and_padMethod · 0.80
set_hide_zticksMethod · 0.80
set_hide_yticksMethod · 0.80
set_hide_xticksMethod · 0.80
set_subplot_3dMethod · 0.80
set_zmaxMethod · 0.80
set_zminMethod · 0.80
set_ymaxMethod · 0.80

Tested by

no test coverage detected