-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot.bqn
50 lines (41 loc) · 1.01 KB
/
plot.bqn
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
# Plots
## Low-level ot.Plot API
{ x0←↕15,
•plot.Plot {
marks⇐⟨
{type⇐"line"⋄x⇐↕15⋄y⇐↕15}
{type⇐"dot"⋄x⇐x0⋄y⇐x0⋄fill⇐<"red"} # faceted
{type⇐"frame"}
⟩
facet⇐{data⇐x0⋄x⇐2|data⋄y⇐3|data}
}
},
## Line plots
Line←{
𝕊y: (↕∘⊑∘⌽≢)⊸𝕊y;
x𝕊y:
marks←{
1: <{type⇐"line",x⇐x,y⇐y};
2:(↕∘≠{type⇐"line",x⇐x,y⇐𝕩,stroke⇐𝕨}˘⊢)y;
"•plot.Line: 𝕩 must be 0-rank or 1-rank array"!0
}=y
•plot.Plot {marks⇐{type⇐"frame"}∾marks},y
},
x←0.1×↕250
cos←•math.Cos x
sin←•math.Sin x,
x Line (1.5×cos)∾sin∾cos≍sin×cos,
Line •math.Cos¨((1+↕5)×⌜0.025×↕100)
# Bar plots
BarY←{x𝕊y:
marks←{type⇐"bary",x⇐x,y⇐y}
•plot.Plot {marks⇐{type⇐"frame"}∾marks}
x
}
BarX←{y𝕊x:
marks←{type⇐"barx",x⇐x,y⇐y}
•plot.Plot {marks⇐{type⇐"frame"}∾marks}
x
},
"ABC" BarY 2‿4‿20,
"ABC" BarX 2‿4‿20,