1+ # set page (width : auto , height : auto )
2+ # import " /src/cetz.typ" : *
3+ # import " /src/lib.typ" : *
4+ # import " /tests/helper.typ" : *
5+
6+ # let data = csv (" testdata.csv" ). map (
7+ ((x , y ,.. ))=> {
8+ (
9+ float (x ),
10+ float (y ),
11+ if x in (" 41" ,) {
12+ (stroke : (paint : red ))
13+ } else if x in (" 93" ,){
14+ (stroke : (paint : blue ))
15+ },
16+ )
17+ }
18+ )
19+
20+ = General case
21+ - Input data is an array of the form (mz, int, ..)
22+ - keys are not explicitly set.
23+ - X, Y ranges not set
24+
25+ # test-case ({
26+ plot . plot (
27+ size : (10 ,6 ),
28+ // y-max: 100,
29+ // x-min: 0, x-max: 175,
30+ {
31+ plot . add-comb (
32+ label : " Linalool, 70eV" ,
33+ // style-key: 2,
34+ // style: (stroke: (paint: black)),
35+ data
36+ )
37+ }
38+ )
39+ })
40+
41+
42+ = With domain set
43+ - General case, but X Y domains are defined explicitly and without mistake
44+
45+ # table (
46+ columns : 3 ,
47+ .. (for i in range (0 , 9 ) {
48+ let (x ,y ) = (calc . div-euclid (i , 3 ),calc . rem-euclid (i , 3 ))
49+ (table . cell ( x : x , y : 3 - y , test-case ({
50+ plot . plot (
51+ x-label : none , y-label : none ,
52+ x-tick-step : none , y-tick-step : none ,
53+ size : (3 ,3 ),
54+ x-min : x * 50 , x-max : (x + 1 ) * 50 ,
55+ y-min : y * 33 , y-max : (y + 1 ) * 33 ,
56+ {
57+ plot . add-comb (
58+ data
59+ )
60+ }
61+ )
62+ })),)
63+ })
64+ )
65+
66+ = With uniform style
67+ Applying the same style to the whole series
68+
69+ # test-case ({
70+ plot . plot (
71+ size : (10 ,6 ),
72+ // y-max: 100,
73+ // x-min: 0, x-max: 175,
74+ {
75+ plot . add-comb (
76+ label : " Linalool, 70eV" ,
77+ // style-key: 2,
78+ style : (stroke : (paint : black , dash : " dashed" )),
79+ data
80+ )
81+ }
82+ )
83+ })
84+
85+ = With uniform style and individual style
86+ Applying the same style across a whole series, except for some for which it is defined explicitly\ as a field set by `style-key`
87+
88+ # test-case ({
89+ plot . plot (
90+ size : (10 ,6 ),
91+ // y-max: 100,
92+ // x-min: 0, x-max: 175,
93+ {
94+ plot . add-comb (
95+ label : " Linalool, 70eV" ,
96+ style-key : 2 ,
97+ style : (stroke : (paint : black , dash : " dashed" )),
98+ data
99+ )
100+ }
101+ )
102+ })
103+
104+ = With Marks
105+ Uniform marks across the series
106+
107+ # test-case ({
108+ plot . plot (
109+ size : (10 ,6 ),
110+ // y-max: 100,
111+ x-min : 35 , x-max : 45 ,
112+ {
113+ plot . add-comb (
114+ label : " Linalool, 70eV" ,
115+ mark : " -" ,
116+ mark-size : 0.2 ,
117+ data
118+ )
119+ // plot.add(domain: (0, 100), x=>x, mark: "x")
120+ }
121+ )
122+ })
123+
124+ = Axis swap
125+ // Test pending upstream
126+ # test-case ({
127+ plot . plot (
128+ size : (10 ,6 ),
129+ y-max : 0 , y-min : 180 ,
130+ // x-min: 35, x-max: 45,
131+ {
132+ plot . add-comb (
133+ axes : (" y" , " x" ),
134+ label : " Linalool, 70eV" ,
135+ // mark: "-",
136+ mark-size : 0.2 ,
137+ data
138+ )
139+ // plot.add(domain: (0, 100), x=>x, mark: "x")
140+ }
141+ )
142+ })
143+
144+ = Logarithym
145+ // Test pending upstream
146+ # test-case ({
147+ plot . plot (
148+ size : (10 ,6 ),
149+ // x-min: 35, x-max: 45,
150+ y-max : 100 ,
151+ y-mode : " log" , y-tick-step : 1 , y-base : 10 , y-format : " sci" , y-minor-tick-step : 1 ,
152+ {
153+ plot . add-comb (
154+ label : " Linalool, 70eV" ,
155+ mark : " o" ,
156+ mark-size : 0.2 ,
157+ data
158+ )
159+ // plot.add(domain: (0, 100), x=>x, mark: "x")
160+ }
161+ )
162+ })
163+
164+ # test-case ({
165+ plot . plot (
166+ size : (10 ,6 ),
167+ x-min : 10 , x-max : 1000 ,
168+ y-max : 100 , y-tick-step : 20 ,
169+ x-mode : " log" , x-tick-step : 1 , x-base : 10 , x-format : " sci" ,
170+ {
171+ plot . add-comb (
172+ label : " Linalool, 70eV" ,
173+ mark : " x" ,
174+ mark-size : 0.2 ,
175+ data
176+ )
177+ }
178+ )
179+ })
0 commit comments