diff options
Diffstat (limited to 'examples/relative_size.rs')
-rw-r--r-- | examples/relative_size.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/relative_size.rs b/examples/relative_size.rs index b0c70fa..66eaec1 100644 --- a/examples/relative_size.rs +++ b/examples/relative_size.rs @@ -28,9 +28,9 @@ fn draw_chart<B: DrawingBackend>(root: &DrawingArea<B, Shift>) -> DrawResult<(), Ok(()) } +const OUT_FILE_NAME: &'static str = "plotters-doc-data/relative_size.png"; fn main() -> Result<(), Box<dyn std::error::Error>> { - let root = - BitMapBackend::new("plotters-doc-data/relative_size.png", (1024, 768)).into_drawing_area(); + let root = BitMapBackend::new(OUT_FILE_NAME, (1024, 768)).into_drawing_area(); root.fill(&WHITE)?; @@ -42,8 +42,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { draw_chart(&upper)?; draw_chart(&lower)?; + let root = root.shrink((200, 200), (150, 100)); + draw_chart(&root)?; - draw_chart(&root.shrink((200, 200), (150, 100)))?; + // 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(()) } |