|
3 | 3 | #import "/tests/helper.typ": *
|
4 | 4 | #import "/src/lib.typ": *
|
5 | 5 | #import cetz: draw, canvas
|
6 |
| -#import cetz-plot: axes, |
7 | 6 |
|
8 | 7 | #test-case({
|
9 |
| - import draw: * |
10 |
| - |
11 | 8 | plot.plot(
|
12 | 9 | size: (9, 6),
|
13 |
| - axis-style: "scientific", |
14 |
| - y-mode: "log", y-base: 10, |
15 | 10 | y-format: "sci",
|
16 | 11 | x-min: 1, x-max: 10, x-tick-step: 1,
|
17 | 12 | y-min: 1, y-max: 10000, y-tick-step: 1, y-minor-tick-step: 1,
|
18 | 13 | x-grid: "both",
|
19 | 14 | y-grid: "both",
|
20 | 15 | {
|
| 16 | + plot.log-axis("y", base: 10) |
| 17 | + |
21 | 18 | plot.add(
|
22 | 19 | domain: (0, 10),
|
23 | 20 | x => {calc.pow(10, x)},
|
24 | 21 | samples: 100,
|
25 |
| - line: "raw", |
26 | 22 | label: $ y=10^x $,
|
27 | 23 | )
|
| 24 | + |
28 | 25 | plot.add(
|
29 | 26 | domain: (1, 10),
|
30 | 27 | x => {x},
|
31 | 28 | samples: 100,
|
32 |
| - line: "raw", |
33 | 29 | hypograph: true,
|
34 | 30 | label: $ y=x $,
|
35 | 31 | )
|
36 | 32 | }
|
37 | 33 | )
|
38 | 34 | })
|
39 | 35 |
|
| 36 | +// Column chart test |
| 37 | +#test-case({ |
| 38 | + plot.plot( |
| 39 | + size: (9, 6), |
| 40 | + y-format: "sci", |
| 41 | + x-min: -0.5, x-max: 4.5, x-tick-step: 1, |
| 42 | + y-min: 0.1, y-max: 10000, step: 1, minor-step: 1, |
| 43 | + x-grid: "both", |
| 44 | + y-grid: "both", |
| 45 | + { |
| 46 | + plot.log-axis("y") |
| 47 | + plot.add-bar( |
| 48 | + (1, 10, 100, 1000, 10000).enumerate().map(((x,y))=>{(x,y)}), |
| 49 | + bar-width: 0.8, |
| 50 | + ) |
| 51 | + } |
| 52 | + ) |
| 53 | +}) |
40 | 54 | // Bode plot test
|
41 | 55 | #box(stroke: 2pt + red,{
|
42 | 56 | canvas({
|
|
47 | 61 | )
|
48 | 62 | plot.plot(
|
49 | 63 | size: (16, 6),
|
50 |
| - axis-style: "scientific", |
51 | 64 | x-format: none, x-label: none,
|
52 | 65 | x-mode: "log",
|
53 | 66 | x-min: 0.01, x-max: 100, x-tick-step: 1, x-minor-tick-step: 1,
|
|
68 | 81 | )
|
69 | 82 | plot.plot(
|
70 | 83 | size: (16, 6),
|
71 |
| - axis-style: "scientific", |
72 | 84 | x-mode: "log",
|
73 | 85 | x-min: 0.01, x-max: 100, x-tick-step: 1, x-minor-tick-step: 1,
|
74 | 86 | x-label: [Frequency ($upright(r a d)\/s$)],
|
|
83 | 95 | })
|
84 | 96 | })
|
85 | 97 |
|
86 |
| -// Column chart test |
87 |
| -#box(stroke: 2pt + red, canvas({ |
88 |
| - import draw: * |
89 |
| - |
90 |
| - plot.plot( |
91 |
| - size: (9, 6), |
92 |
| - axis-style: "scientific", |
93 |
| - y-mode: "log", y-base: 10, |
94 |
| - y-format: "sci", |
95 |
| - x-min: -0.5, x-max: 4.5, x-tick-step: 1, |
96 |
| - y-min: 0.1, y-max: 10000, y-tick-step: 1, y-minor-tick-step: 1, |
97 |
| - x-grid: "both", |
98 |
| - y-grid: "both", |
99 |
| - { |
100 |
| - plot.add-bar( |
101 |
| - (1, 10, 100, 1000, 10000).enumerate().map(((x,y))=>{(x,y)}), |
102 |
| - bar-width: 0.8, |
103 |
| - ) |
104 |
| - } |
105 |
| - ) |
106 |
| -})) |
107 | 98 |
|
108 | 99 | // Scatter plot test
|
109 | 100 | #box(stroke: 2pt + red, canvas({
|
110 | 101 | import draw: *
|
111 | 102 |
|
112 | 103 | plot.plot(
|
113 | 104 | size: (9, 6),
|
114 |
| - axis-style: "scientific", |
115 | 105 | y-mode: "log", y-base: 100,
|
116 | 106 | y-format: "sci",
|
117 | 107 | x-min: -0.5, x-max: 4.5, x-tick-step: 1,
|
|
135 | 125 | }
|
136 | 126 | )
|
137 | 127 | }))
|
| 128 | +*/ |
138 | 129 |
|
139 | 130 | // Box plot test
|
140 |
| -#box(stroke: 2pt + red, canvas({ |
| 131 | +#test-case({ |
141 | 132 | import draw: *
|
142 | 133 |
|
143 | 134 | plot.plot(
|
144 | 135 | size: (9, 6),
|
145 |
| - axis-style: "scientific", |
146 |
| - y-mode: "log", y-base: 10, |
147 | 136 | y-format: "sci",
|
148 | 137 | x-min: -0.5, x-max: 2.5, x-tick-step: 1,
|
149 | 138 | y-min: 0.1, y-max: 15000, y-tick-step: 1, y-minor-tick-step: 1,
|
150 | 139 | x-grid: "both",
|
151 | 140 | y-grid: "both",
|
152 | 141 | {
|
| 142 | + plot.log-axis("y") |
153 | 143 | plot.add-boxwhisker(
|
154 | 144 | (
|
155 | 145 | (x: 0, min: 1, q1: 10, q2: 100, q3: 1000, max: 10000),
|
|
159 | 149 | )
|
160 | 150 | }
|
161 | 151 | )
|
162 |
| -})) |
| 152 | +}) |
0 commit comments