Read data from CSV file
This commit is contained in:
parent
5c8e3c9234
commit
6301fa651d
3 changed files with 13 additions and 10 deletions
|
@ -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;
|
#+ATTR_HTML: :width 100% :style margin-left: auto; margin-right: auto;
|
||||||
[[./demo.png]]
|
[[./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
|
** Features
|
||||||
|
|
||||||
- Braille canvas for plotting
|
- Braille canvas for plotting
|
||||||
|
|
BIN
demo.png
BIN
demo.png
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 23 KiB |
21
demo.ss
21
demo.ss
|
@ -2,16 +2,17 @@
|
||||||
|
|
||||||
(export main)
|
(export main)
|
||||||
|
|
||||||
(import :std/format
|
(import :std/iter
|
||||||
:std/misc/string
|
:std/text/csv
|
||||||
:dlozeve/fancy/format
|
|
||||||
:dlozeve/uniplot/lineplot)
|
:dlozeve/uniplot/lineplot)
|
||||||
|
|
||||||
(def (main . args)
|
(def (main . args)
|
||||||
(let* ((xs (iota 1000 0 0.01))
|
(def csv (read-csv-lines (current-input-port)))
|
||||||
(ys1 (map cos xs))
|
(def names (car csv))
|
||||||
(ys2 (map (lambda (x) (/ 1 (+ 0.5 x))) xs))
|
(def lsts
|
||||||
(ys3 (map (lambda (x) (sin (* 2 x))) xs)))
|
(apply map list
|
||||||
(displayln (line-plot [xs ys1 ys2 ys3]
|
(for/collect ((row csv))
|
||||||
xlabel: "time"
|
(for/collect ((x row))
|
||||||
names: ["cos(time)" "1 / (time + 0.5)" "sin(2 × time)"]))))
|
(or (string->number x) +nan.0)))))
|
||||||
|
(displayln (line-plot lsts
|
||||||
|
xlabel: (car names) names: (cdr names))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue