-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmanual.typ
90 lines (69 loc) · 2.04 KB
/
manual.typ
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#import "/src/cetz.typ"
#import "/doc/util.typ": *
#import "/doc/example.typ": example
#import "/doc/style.typ" as doc-style
#import "/src/lib.typ": *
#import "@preview/tidy:0.3.0"
// Usage:
// ```example
// /* canvas drawing code */
// ```
#show raw.where(lang: "example"): example
#show raw.where(lang: "example-vertical"): example.with(vertical: true)
#make-title()
#set terms(indent: 1em)
#set par(justify: true)
#set heading(numbering: (..num) => if num.pos().len() < 4 {
numbering("1.1", ..num)
})
#show link: set text(blue)
// Outline
#{
show heading: none
columns(2, outline(indent: auto, depth: 3))
pagebreak(weak: true)
}
#set page(numbering: "1/1", header: align(right)[CeTZ-Plot])
= Introduction
CeTZ-Plot is a simple plotting library for use with CeTZ.
= Usage
This is the minimal starting point:
#pad(left: 1em)[```typ
#import "@preview/cetz:0.3.1"
#import "@preview/cetz-plot:0.1.0"
#cetz.canvas({
import cetz.draw: *
import cetz-plot: *
...
})
```]
Note that plot functions are imported inside the scope of the `canvas` block.
All following example code is expected to be inside a `canvas` block, with the `plot`
module imported into the namespace.
= Plot
#doc-style.parse-show-module("/src/plot.typ")
#for m in ("line", "bar", "boxwhisker", "contour", "errorbar", "annotation", "formats", "violin", "legend") {
doc-style.parse-show-module("/src/plot/" + m + ".typ")
}
== Styling
You can use style root `axes` with the following keys:
#doc-style.parse-show-module("/src/axes.typ")
=== Example
```example
import cetz.draw: *
import cetz-plot: *
set-style(axes: (
stroke: (dash: "dotted", paint: gray),
x: (mark: (start: ">", end: ">"), padding: 1),
y: (mark: none),
tick: (stroke: gray + .5pt),
))
plot.plot(size: (5, 4), axis-style: "school-book", y-tick-step: none, {
plot.add(calc.sin, domain: (0, calc.pi * 2))
})
```
= Chart
#doc-style.parse-show-module("/src/chart.typ")
#for m in ("barchart", "boxwhisker", "columnchart", "piechart", "pyramid") {
doc-style.parse-show-module("/src/chart/" + m + ".typ")
}