aboutsummaryrefslogtreecommitdiff
path: root/src/p.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-09-18 08:11:24 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-09-18 08:25:54 -0400
commit3c21d1e0f7535faa23fbb6fe0959675833d140b7 (patch)
treeeaf6029f95b12af7d289fb9b819cce5ab89d5245 /src/p.bqn
parentc3a4f00fde95d989256f7df68fac4d8cc21e5489 (diff)
Avoid NaN in •Plot when all x or y values are the same
Diffstat (limited to 'src/p.bqn')
-rw-r--r--src/p.bqn3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/p.bqn b/src/p.bqn
index 2c9972e4..a3fa568f 100644
--- a/src/p.bqn
+++ b/src/p.bqn
@@ -26,7 +26,8 @@ PairRec ← {
Plot ← {
xy ← 1e300 (⊣-⊸⌈⌊) ⍉> 𝕨 PairRec 𝕩 # organize and clip
pts ← <∘∾˘ xy
- win ← -˜`¨ bounds ← (⌊´≍⌈´)¨ pts # min and range; min and max
+ AB ← {e←(÷5e15)(⊣×⌈´)|𝕩⋄(⌊≍⌈)˝⌾(-⟜0‿e)𝕩} # ensure 0 < window size
+ win ← -˜`¨ bounds ← (AB ⌊´≍⌈´)¨ pts # min and range; min and max
ar ← 1⍟((÷4)⊸>∨1.5⊸<) ÷˜´ 1⊑¨win # height÷width
dim ← width (⊣≍×) ar
Scale ← ({¬𝕏}⌾(1⊸⊑) {𝕩÷˜𝕨-˜⊢}´¨ win) {𝕎𝕩}¨ ⊢