MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / new

Function new

examples/log_scale.rs:24–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22}
23
24fn 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}

Callers

nothing calls this directly

Calls 14

log_tick_producerFunction · 0.85
log_formatterFunction · 0.85
buildMethod · 0.80
with_y_tick_formatterMethod · 0.80
with_x_tick_formatterMethod · 0.80
with_y_tick_producerMethod · 0.80
with_x_tick_producerMethod · 0.80
with_y_scaleMethod · 0.80
with_x_scaleMethod · 0.80
with_y_labelMethod · 0.80
with_x_labelMethod · 0.80
with_colorMethod · 0.45

Tested by

no test coverage detected