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

Function new_scatter

examples/huge_scatter.rs:36–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36fn new_scatter() -> PlotWidget {
37 // Generate 5 million points from 2D Gaussian
38 let mut rng = rand::rng();
39 let normal = Normal::new(0.0f64, 1.0f64).unwrap();
40 let positions = (0..5_000_000)
41 .map(|_| [normal.sample(&mut rng), normal.sample(&mut rng)])
42 .collect::<Vec<[f64; 2]>>();
43
44 let series = Series::markers_only(positions, MarkerStyle::circle(1.0))
45 .with_label("2d Gaussian scatter - 5M points")
46 .with_color(Color::from_rgb(0.2, 0.6, 1.0));
47
48 PlotWidgetBuilder::new()
49 .with_hover_highlight_provider(|context, point| {
50 point.color = Color::from_rgb(1.0, 0.5, 0.2);
51 point.resize_marker(1.5);
52 Some(format!(
53 "point: {}\nx: {:.3}, y: {:.3}",
54 context.point_index, point.x, point.y
55 ))
56 })
57 .with_pick_highlight_provider(|context, point| {
58 point.color = Color::from_rgb(1.0, 0.0, 0.0);
59 point.mask_padding = None;
60 point.resize_marker(3.0);
61 Some(format!(
62 "point: {}\nx: {:.3}, y: {:.3}",
63 context.point_index, point.x, point.y
64 ))
65 })
66 .add_series(series.clone())
67 .build()
68 .unwrap()
69}

Callers

nothing calls this directly

Calls 9

mapMethod · 0.80
buildMethod · 0.80
resize_markerMethod · 0.80
newFunction · 0.70
with_colorMethod · 0.45
with_labelMethod · 0.45
add_seriesMethod · 0.45

Tested by

no test coverage detected