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

Function new

examples/transform.rs:39–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37}
38
39fn new() -> PlotWidget {
40 let identity = Series::line_only(
41 sample(160, |t| {
42 let x = t * 2.0;
43 [x, (TAU * t).sin() * 0.55]
44 }),
45 LineStyle::solid().with_pixel_width(2.0),
46 )
47 .with_transform(PositionTransform::new(Some(Transform::identity()), None))
48 .with_label("identity data")
49 .with_color(Color::from_rgb(0.2, 0.6, 1.0));
50
51 let affine_y = Series::line_only(
52 sample(160, |t| {
53 let x = t * 2.0;
54 let normalized = ((TAU * t).cos() * 0.5 + 0.5).clamp(0.0, 1.0);
55 [x, normalized]
56 }),
57 LineStyle::dashed(8.0).with_pixel_width(2.0),
58 )
59 .with_transform_y(Transform::affine(2.0, -1.0))
60 .with_label("y affine: y * 2 - 1")
61 .with_color(Color::from_rgb(0.9, 0.45, 0.15));
62
63 let log_x = Series::line_only(
64 sample(160, |t| {
65 let x_plot = t * 2.0;
66 [10.0_f64.powf(x_plot), 1.05 + (TAU * t).sin() * 0.25]
67 }),
68 LineStyle::solid().with_pixel_width(2.0),
69 )
70 .with_transform_x(Transform::log(10.0))
71 .with_label("x log10(raw)")
72 .with_color(Color::from_rgb(0.35, 0.85, 0.4));
73
74 let exp_y = Series::line_only(
75 sample(160, |t| {
76 let x = t * 2.0;
77 let y_after_transform = 1.25 + x * 0.45;
78 [x, y_after_transform.ln()]
79 }),
80 LineStyle::dotted(5.0).with_pixel_width(2.5),
81 )
82 .with_transform_y(Transform::exp(E))
83 .with_label("y exp(raw)")
84 .with_color(Color::from_rgb(0.85, 0.2, 0.55));
85
86 let composed_x = Series::line_only(
87 sample(160, |t| [t, 2.45 + (TAU * t).cos() * 0.22]),
88 LineStyle::dashed(5.0).with_pixel_width(2.0),
89 )
90 .with_transform_x(Transform::affine(99.0, 1.0).then(Transform::log(10.0)))
91 .with_label("x (raw * 99 + 1) then log10")
92 .with_color(Color::from_rgb(0.65, 0.45, 0.95));
93
94 let axes_line = Series::line_only(
95 vec![[0.05, 0.88], [0.95, 0.88]],
96 LineStyle::solid().with_pixel_width(3.0),

Callers

nothing calls this directly

Calls 15

sampleFunction · 0.85
with_pixel_widthMethod · 0.80
thenMethod · 0.80
buildMethod · 0.80
with_cursor_overlayMethod · 0.80
with_y_limMethod · 0.80
with_x_limMethod · 0.80
with_y_labelMethod · 0.80
with_x_labelMethod · 0.80
with_colorMethod · 0.45
with_labelMethod · 0.45
with_transformMethod · 0.45

Tested by

no test coverage detected