| 76 | |
| 77 | impl PlottersChart for MyChart { |
| 78 | fn plot( |
| 79 | &mut self, |
| 80 | root: &DrawingArea<GpuiBackend, Shift>, |
| 81 | ) -> Result<(), plotters_gpui::DrawingErrorKind> { |
| 82 | root.fill(&WHITE).unwrap(); |
| 83 | |
| 84 | self.next(); |
| 85 | |
| 86 | let mut chart = ChartBuilder::on(root) |
| 87 | .caption("2D Gaussian PDF", ("sans-serif", 20)) |
| 88 | .build_cartesian_3d(-3.0..3.0, 0.0..6.0, -3.0..3.0) |
| 89 | .unwrap(); |
| 90 | chart.with_projection(|mut p| { |
| 91 | p.pitch = 1.57 - (1.57 - self.pitch as f64 / 50.0).abs(); |
| 92 | p.scale = 0.7; |
| 93 | p.into_matrix() // build the projection matrix |
| 94 | }); |
| 95 | |
| 96 | chart |
| 97 | .configure_axes() |
| 98 | .light_grid_style(BLACK.mix(0.15)) |
| 99 | .max_light_lines(3) |
| 100 | .draw() |
| 101 | .unwrap(); |
| 102 | |
| 103 | chart |
| 104 | .draw_series( |
| 105 | SurfaceSeries::xoz( |
| 106 | (-15..=15).map(|x| x as f64 / 5.0), |
| 107 | (-15..=15).map(|x| x as f64 / 5.0), |
| 108 | pdf, |
| 109 | ) |
| 110 | .style_func(&|&v| (VulcanoHSL::get_color(v / 5.0)).into()), |
| 111 | ) |
| 112 | .unwrap(); |
| 113 | |
| 114 | root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir"); |
| 115 | |
| 116 | Ok(()) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | fn main_viewer(cx: &mut App) -> MainViewer { |