plot_values

Function plot_values 

Source
pub fn plot_values(
    values: &[f64],
    title: Option<&str>,
    width: Option<usize>,
    height: Option<usize>,
) -> Result<(), Box<dyn Error>>
Expand description

Plot any slice of f64 values with automatic dynamic scaling

§Arguments

  • values - The data values to plot
  • title - Optional title for the plot
  • width - Optional plot width (default: 140)
  • height - Optional plot height (default: 60)

§Examples

use rusty_tip::plotting::plot_values;

let data = vec![1e-12, 2e-12, 1.5e-12, 3e-12];
plot_values(&data, Some("Current Signal"), None, None).unwrap();
Examples found in repository?
examples/test_stable_signal.rs (line 37)
4fn main() -> Result<(), Box<dyn Error>> {
5    let mut driver = ActionDriver::new("127.0.0.1", 6501)?;
6
7    let _freq_shift = rusty_tip::SignalIndex(76);
8
9    let z_pos = rusty_tip::SignalIndex(30);
10
11    driver.execute(rusty_tip::Action::Withdraw {
12        wait_until_finished: true,
13        timeout: Duration::from_secs(5),
14    })?;
15
16    driver.execute(rusty_tip::Action::AutoApproach {
17        wait_until_finished: true,
18        timeout: Duration::from_secs(300),
19    })?;
20
21    if let Some(osci_data) = driver.read_oscilloscope_with_stability(
22        z_pos,
23        // Some(TriggerConfig::new(
24        //     rusty_tip::types::OsciTriggerMode::Level,
25        //     rusty_tip::TriggerSlope::Falling,
26        //     49.0e-12,
27        //     0.0,
28        // )),
29        None,
30        rusty_tip::types::DataToGet::Stable {
31            readings: 1,
32            timeout: Duration::from_secs(2),
33        },
34        stability::trend_analysis_stability,
35    )? {
36        // Use the new plotting function - much cleaner!
37        rusty_tip::plot_values(&osci_data.data, Some("Z-Position Oscilloscope Data"), None, None)?;
38
39        let is_stable = stability::trend_analysis_stability(&osci_data.data);
40        println!("Stability result: {}", is_stable);
41    };
42
43    Ok(())
44}