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

Function plot_widget

examples/plot_overlays.rs:168–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166}
167
168fn plot_widget() -> PlotWidget {
169 let line = Series::line_only(
170 (0..240)
171 .map(|i| {
172 let x = i as f64 / 239.0 * TAU;
173 [x, x.sin()]
174 })
175 .collect(),
176 LineStyle::solid().with_pixel_width(2.0),
177 )
178 .with_label("sin(x)")
179 .with_color(Color::from_rgb(0.2, 0.55, 0.9));
180
181 let peak = Series::markers_only(vec![[FRAC_PI_2, 1.0]], MarkerStyle::circle(6.0))
182 .with_label("peak")
183 .with_color(Color::from_rgb(0.95, 0.25, 0.25));
184
185 let trough = Series::markers_only(vec![[FRAC_PI_2 * 3.0, -1.0]], MarkerStyle::circle(6.0))
186 .with_label("trough")
187 .with_color(Color::from_rgb(0.95, 0.45, 0.15));
188
189 PlotWidgetBuilder::new()
190 .with_x_label("x")
191 .with_y_label("sin(x)")
192 .with_x_lim(0.0, TAU)
193 .with_y_lim(-1.25, 1.25)
194 .add_series(line)
195 .add_series(peak)
196 .add_series(trough)
197 .with_cursor_overlay(true)
198 .build()
199 .unwrap()
200}
201
202fn region_style(theme: &Theme) -> container::Style {
203 let palette = theme.extended_palette();

Callers 1

newMethod · 0.70

Calls 12

mapMethod · 0.80
with_pixel_widthMethod · 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
newFunction · 0.70
with_colorMethod · 0.45
with_labelMethod · 0.45
add_seriesMethod · 0.45

Tested by

no test coverage detected