File: text.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 (65 lines) | stat: -rw-r--r-- 1,263 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This file is released into Public Domain.
use crate::common::*;
use gnuplot::*;

mod common;

fn example(c: Common)
{
	let mut fg = Figure::new();
	let _ax = fg
		.axes2d()
		.label(
			"multi\nline string",
			Coordinate::Graph(0.5),
			Coordinate::Graph(0.9),
			&[],
		)
		.label(
			"x^2 x_2 {/Times*2 abc} \\{\\}\\^\\_",
			Coordinate::Graph(0.5),
			Coordinate::Graph(0.8),
			&[],
		)
		.label(
			"Monospace",
			Coordinate::Graph(0.5),
			Coordinate::Graph(0.6),
			&[Font("Monospace", 32.)],
		)
		.label(
			"Align Right",
			Coordinate::Graph(0.5),
			Coordinate::Graph(0.5),
			&[TextAlign(AlignRight)],
		)
		.label(
			"Align Centre",
			Coordinate::Graph(0.5),
			Coordinate::Graph(0.4),
			&[TextAlign(AlignCenter)],
		)
		.label(
			"~{Over}{Print}", // Why does gnuplot have this feature?
			Coordinate::Graph(0.5),
			Coordinate::Graph(0.3),
			&[TextAlign(AlignCenter)],
		)
		.label(
			"Tab\tCharacter", // Strange rendering on this one
			Coordinate::Graph(0.5),
			Coordinate::Graph(0.2),
			&[TextAlign(AlignCenter)],
		)
		.lines(&[-2., -2.], &[-3., 3.], &[])
		.set_x_ticks(None, &[], &[])
		.set_y_ticks(None, &[], &[])
		.set_border(true, &[], &[]);

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

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