()
| 1 | use plotters::prelude::*; |
| 2 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 3 | let root = BitMapBackend::new("plotters-doc-data/0.png", (640, 480)).into_drawing_area(); |
| 4 | root.fill(&WHITE)?; |
| 5 | let mut chart = ChartBuilder::on(&root) |
| 6 | .caption("y=x^2", ("sans-serif", 50).into_font()) |
| 7 | .margin(5) |
| 8 | .x_label_area_size(30) |
| 9 | .y_label_area_size(30) |
| 10 | .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?; |
| 11 | |
| 12 | chart.configure_mesh().draw()?; |
| 13 | |
| 14 | chart |
| 15 | .draw_series(LineSeries::new( |
| 16 | (-50..=50).map(|x| x as f32 / 50.0).map(|x| (x, x * x)), |
| 17 | &RED, |
| 18 | ))? |
| 19 | .label("y = x^2") |
| 20 | .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &RED)); |
| 21 | |
| 22 | chart |
| 23 | .configure_series_labels() |
| 24 | .background_style(&WHITE.mix(0.8)) |
| 25 | .border_style(&BLACK) |
| 26 | .draw()?; |
| 27 | |
| 28 | Ok(()) |
| 29 | } |
nothing calls this directly
no outgoing calls
no test coverage detected