File: time.rs

package info (click to toggle)
rust-gnuplot 0.0.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 532 kB
  • sloc: makefile: 2
file content (47 lines) | stat: -rw-r--r-- 931 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// This file is released into Public Domain.
use crate::common::*;
use gnuplot::*;
use std::time::Duration;

mod common;

fn example(c: Common)
{
	let x1 = &[
		Duration::from_secs(0),
		Duration::from_secs(3600 * 12),
		Duration::from_secs(3600 * 24),
		Duration::from_secs(3600 * 36),
	];
	let x2 = &[
		Duration::from_millis(0),
		Duration::from_millis(500),
		Duration::from_millis(1000),
		Duration::from_millis(1500),
	];
	let y = &[0i32, -1, 1, 0];

	let mut fg = Figure::new();

	fg.axes2d()
		.set_title("Time 1: Hours", &[])
		.lines(x1, y, &[])
		.set_x_ticks(Some((Auto, 1)), &[Format("%H hours")], &[])
		.set_x_time(true);

	c.show(&mut fg, "time_1");

	let mut fg = Figure::new();
	fg.axes2d()
		.set_title("Time 2: Seconds", &[])
		.lines(x2, y, &[])
		.set_x_ticks(Some((Auto, 1)), &[Format("%.1S secs")], &[])
		.set_x_time(true);

	c.show(&mut fg, "time_2");
}

fn main()
{
	Common::new().map(|c| example(c));
}