()
| 22 | } |
| 23 | |
| 24 | fn new() -> PlotWidget { |
| 25 | let mut values = Vec::new(); |
| 26 | for i in -10..=200 { |
| 27 | let x = i as f64 * 0.1; |
| 28 | let y = x * x + 0.05; |
| 29 | values.push([x, y]); |
| 30 | } |
| 31 | |
| 32 | let series = Series::circles(values, 4.0) |
| 33 | .with_label("y = x² + 0.05") |
| 34 | .with_color(Color::from_rgb(0.2, 0.8, 1.0)); |
| 35 | |
| 36 | // Build a log-log plot. |
| 37 | // |
| 38 | // Note that we also override the tick producers to place ticks on powers, |
| 39 | // and the formatters to use scientific notation. This is optional. You could |
| 40 | // use the built-in ones if you don't need evenly spaced ticks, or provide your |
| 41 | // own. |
| 42 | PlotWidgetBuilder::new() |
| 43 | .with_x_label("x") |
| 44 | .with_y_label("y") |
| 45 | .with_x_scale(AxisScale::Log { base: E }) |
| 46 | .with_y_scale(AxisScale::Log { base: E }) |
| 47 | .with_x_tick_producer(|min, max, width_px| log_tick_producer(E, min, max, width_px)) |
| 48 | .with_y_tick_producer(|min, max, height_px| log_tick_producer(E, min, max, height_px)) |
| 49 | .with_x_tick_formatter(|t| log_formatter(t, E)) |
| 50 | .with_y_tick_formatter(|t| log_formatter(t, E)) |
| 51 | .add_series(series) |
| 52 | .build() |
| 53 | .unwrap() |
| 54 | } |
nothing calls this directly
no test coverage detected