diff --git a/README.org b/README.org index fcbba92..98361b8 100644 --- a/README.org +++ b/README.org @@ -7,6 +7,8 @@ Depends on [[https://github.com/dlozeve/fancy][Fancy]] for colors and display. #+ATTR_HTML: :width 100% :style margin-left: auto; margin-right: auto; [[./demo.png]] +Annual CO₂ emissions (t) (source: [[https://ourworldindata.org/grapher/annual-co2-emissions-per-country?tab=chart&time=1850..latest&country=CHN~USA~Europe][Our World in Data]]) + ** Features - Braille canvas for plotting diff --git a/demo.png b/demo.png index 8a71543..d0d6330 100644 Binary files a/demo.png and b/demo.png differ diff --git a/demo.ss b/demo.ss index 6cb5a8d..60bb196 100755 --- a/demo.ss +++ b/demo.ss @@ -2,16 +2,17 @@ (export main) -(import :std/format - :std/misc/string - :dlozeve/fancy/format +(import :std/iter + :std/text/csv :dlozeve/uniplot/lineplot) (def (main . args) - (let* ((xs (iota 1000 0 0.01)) - (ys1 (map cos xs)) - (ys2 (map (lambda (x) (/ 1 (+ 0.5 x))) xs)) - (ys3 (map (lambda (x) (sin (* 2 x))) xs))) - (displayln (line-plot [xs ys1 ys2 ys3] - xlabel: "time" - names: ["cos(time)" "1 / (time + 0.5)" "sin(2 × time)"])))) + (def csv (read-csv-lines (current-input-port))) + (def names (car csv)) + (def lsts + (apply map list + (for/collect ((row csv)) + (for/collect ((x row)) + (or (string->number x) +nan.0))))) + (displayln (line-plot lsts + xlabel: (car names) names: (cdr names))))