diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-13 15:37:57 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-13 15:37:57 -0400 |
| commit | 810a53e95015b6636f964331fe10f60a2e683dfa (patch) | |
| tree | 4fd8ebc20e622c0be1696f709d05470caab5d867 /src/p.bqn | |
| parent | 29b00d76e8cc3babbf42efa1ab1c6ae4106f598a (diff) | |
Multiple plot lines
Diffstat (limited to 'src/p.bqn')
| -rw-r--r-- | src/p.bqn | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -9,15 +9,23 @@ rc ← At "class=code|stroke-width=1|rx=5" gr ← "g" At "font-family=BQN,monospace|font-size=18px" Path ← "path" Elt ⊣∾"d"≍○<⊢ +Pair ← { + "•Plot: 𝕨 and 𝕩 must consist of rows of numbers" ! 𝕨 ⊢⊘∧○((1≤=)◶⟨0,∧´∘⥊@⊸>⟩) 𝕩 + "•Plot: 𝕨 and 𝕩 must have the same length" ! 𝕨 1⊘(≡○(¯1⊑≢)) 𝕩 + ⥊ 𝕨 (< (↕¯1⊑≢)⊘⊣ ≍○< ⊢)⎉1 𝕩 +} +PairRec ← { + d ← 𝕨≍○≡𝕩 + 𝕨 (2≤⌊´d)◶⟨Pair⊣"•Plot: invalid depth mixing"!·∧´1=d˙, ∾∘⥊𝕊¨⟩ 𝕩 +} Plot ← { - "•Plot: 𝕨 and 𝕩 must be lists of numbers" ! 𝕨 ⊢⊘∧○((1==)◶⟨0,∧´@⊸>⟩) 𝕩 - "•Plot: 𝕨 and 𝕩 must have the same length" ! 𝕨 1⊘≡○≠ 𝕩 - xy ← 1e300 (⊣-⊸⌈⌊) ⟨𝕨↕∘≠⊘⊣𝕩, 𝕩⟩ # default x and clip - win ← -˜`¨ bounds ← (⌊´≍⌈´)¨ xy # min and range; min and max + xy ← 1e300 (⊣-⊸⌈⌊) ⍉> 𝕨 PairRec 𝕩 # organize and clip + pts ← <∘∾˘ xy + win ← -˜`¨ bounds ← (⌊´≍⌈´)¨ pts # min and range; min and max ar ← 1⍟((÷4)⊸>∨1.5⊸<) ÷˜´ 1⊑¨win # height÷width dim ← width (⊣≍×) ar Scale ← ({¬𝕏}⌾(1⊸⊑) {𝕩÷˜𝕨-˜⊢}´¨ win) {𝕎𝕩}¨ ⊢ - line ← < 'M'⌾⊑ ∾⥊⍉ "L " ∾¨ FmtNum > dim × Scale xy + line ← {'M'⌾⊑ ∾⥊ "L "∾¨⎉1𝕩}¨ (/≠¨⊏xy) ⊔ FmtNum ⍉> dim×Scale pts ((-pad)∾dim+2×pad) SVG gr Enc ∾⥊¨ ⟨ <"rect" Elt rc∾(Pos-pad÷2)∾"width"‿"height"≍˘FmtNum dim+pad pa⊸Path¨ ((0⊸≤∧≤⟜1)/·<∘∾˘("M "⊸∾˘"VH")∾¨·FmtNum dim×·∾⟜1˘(=⌜˜↕2)⊸×) Scale 0 |
