Skip to main content

plot_sphere/
plot_sphere.rs

1use plotpy::{Plot, StrError, Surface};
2
3fn main() -> Result<(), StrError> {
4    let mut surf = Surface::new();
5    surf.set_surf_color("#ff880090") // Orange with some transparency
6        .set_with_wireframe(true)
7        .set_wire_line_color("black")
8        .draw_sphere(&[0.0, 0.0, 0.0], 1.0, 30, 30)?;
9
10    let mut plot = Plot::new();
11    plot.add(&surf)
12        .set_equal_axes(true) // Forces 1:1:1 aspect ratio so it's a perfect sphere
13        .set_zoom_3d(1.5) // Zooms in optically
14        .set_figure_size_points(800.0, 800.0)
15        .save("/tmp/plotpy/sphere_zoomed.png")?;
16
17    println!("Saved /tmp/plotpy/sphere_zoomed.png");
18
19    Ok(())
20}