diff options
Diffstat (limited to 'examples/two-scales.rs')
-rw-r--r-- | examples/two-scales.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/two-scales.rs b/examples/two-scales.rs index d45f67a..6e1dfa4 100644 --- a/examples/two-scales.rs +++ b/examples/two-scales.rs @@ -1,8 +1,8 @@ use plotters::prelude::*; +const OUT_FILE_NAME: &'static str = "plotters-doc-data/twoscale.png"; fn main() -> Result<(), Box<dyn std::error::Error>> { - let root = - BitMapBackend::new("plotters-doc-data/twoscale.png", (1024, 768)).into_drawing_area(); + let root = BitMapBackend::new(OUT_FILE_NAME, (1024, 768)).into_drawing_area(); root.fill(&WHITE)?; let mut chart = ChartBuilder::on(&root) @@ -48,6 +48,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { .background_style(&RGBColor(128, 128, 128)) .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(()) } #[test] |