aboutsummaryrefslogtreecommitdiff
path: root/examples/normal-dist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/normal-dist.rs')
-rw-r--r--examples/normal-dist.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/normal-dist.rs b/examples/normal-dist.rs
index 20d048a..be48786 100644
--- a/examples/normal-dist.rs
+++ b/examples/normal-dist.rs
@@ -4,9 +4,9 @@ use rand::SeedableRng;
use rand_distr::{Distribution, Normal};
use rand_xorshift::XorShiftRng;
+const OUT_FILE_NAME: &'static str = "plotters-doc-data/normal-dist.png";
fn main() -> Result<(), Box<dyn std::error::Error>> {
- let root =
- BitMapBackend::new("plotters-doc-data/normal-dist.png", (1024, 768)).into_drawing_area();
+ let root = BitMapBackend::new(OUT_FILE_NAME, (1024, 768)).into_drawing_area();
root.fill(&WHITE)?;
@@ -54,6 +54,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
x_hist_ctx.draw_series(x_hist)?;
y_hist_ctx.draw_series(y_hist)?;
+ // To avoid the IO failure being ignored silently, we manually call the present function
+ root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir");
+ println!("Result has been saved to {}", OUT_FILE_NAME);
+
Ok(())
}
#[test]