diff options
Diffstat (limited to 'examples/errorbar.rs')
-rw-r--r-- | examples/errorbar.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/errorbar.rs b/examples/errorbar.rs index 7f11dd9..75c5dbe 100644 --- a/examples/errorbar.rs +++ b/examples/errorbar.rs @@ -8,12 +8,12 @@ use itertools::Itertools; use num_traits::sign::Signed; +const OUT_FILE_NAME: &'static str = "plotters-doc-data/errorbar.png"; fn main() -> Result<(), Box<dyn std::error::Error>> { let data = generate_random_data(); let down_sampled = down_sample(&data[..]); - let root = - BitMapBackend::new("plotters-doc-data/errorbar.png", (1024, 768)).into_drawing_area(); + let root = BitMapBackend::new(OUT_FILE_NAME, (1024, 768)).into_drawing_area(); root.fill(&WHITE)?; @@ -50,6 +50,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { .background_style(WHITE.filled()) .draw()?; + // 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(()) } |