Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Jun 25, 2023
1 parent 57064e9 commit 383e68a
Show file tree
Hide file tree
Showing 6 changed files with 29,905 additions and 14 deletions.
9,880 changes: 9,880 additions & 0 deletions docs/intro/image.html

Large diffs are not rendered by default.

9,925 changes: 9,925 additions & 0 deletions docs/intro/python.html

Large diffs are not rendered by default.

10,009 changes: 10,009 additions & 0 deletions docs/intro/visualization.html

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions notebooks/intro/image.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
(ns intro.image
(:require [scicloj.kind-clerk.api :as kind-clerk]
[tech.v3.tensor :as tensor]
(:require [tech.v3.tensor :as tensor]
[tech.v3.datatype.functional :as fun]
[scicloj.noj.v1.vis.image :as vis.image]))

;; ## Adapt Clerk to Kindly
(kind-clerk/setup!)
;; ## Turning tensors into images

(-> (for [i (range 100)]
(range 100))
Expand Down
5 changes: 0 additions & 5 deletions notebooks/intro/python.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
hiccup.util))


;; ## Setup

;; Adapt Clerk to Kindly
(kind-clerk/setup!)

;; ## Using Python visualizations

(require-python '[numpy :as np]
Expand Down
94 changes: 89 additions & 5 deletions notebooks/intro/visualization.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
[tablecloth.api :as tc]
[aerial.hanami.templates :as ht]
[scicloj.noj.v1.vis :as vis]
[scicloj.noj.v1.stats :as stats]
[tech.v3.datatype :as dtype]
[tech.v3.datatype.functional :as fun]
[scicloj.kindly.v3.api :as kindly]
[scicloj.kindly.v3.kind :as kind]
[hiccup.core :as hiccup]
hiccup.util))
[clojure2d.color :as color]))


;; ## Adapt Clerk to Kindly
(kind-clerk/setup!)

;; ## Raw html
(-> "<p>Hello, <i>Noj</i>.</p>"
vis/raw-html)
Expand All @@ -36,9 +34,95 @@
(repeatedly 9 rand))}
tc/dataset))

;; ### A simple plot

;; plotting a Tablecloth datasete based on a Hanami template

(-> dataset1
(vis/hanami-plot ht/point-chart
:MSIZE 200))
{:MSIZE 200}))

;; ### Layers

(-> dataset1
(vis/hanami-layers
{:TITLE "points and a line"}
[(vis/hanami-plot nil
ht/point-chart
{:MSIZE 400})
(vis/hanami-plot nil
ht/line-chart
{:MSIZE 4
:MCOLOR "brown"})]))

;; ### Concatenation

(-> dataset1
(vis/hanami-vconcat
{}
[(vis/hanami-plot nil
ht/point-chart
{:MSIZE 400
:HEIGHT 100
:WIDTH 100})
(vis/hanami-plot nil
ht/line-chart
{:MSIZE 4
:MCOLOR "brown"
:HEIGHT 100
:WIDTH 100})]))

(-> dataset1
(vis/hanami-hconcat
{}
[(vis/hanami-plot nil
ht/point-chart
{:MSIZE 400
:HEIGHT 100
:WIDTH 100})
(vis/hanami-plot nil
ht/line-chart
{:MSIZE 4
:MCOLOR "brown"
:HEIGHT 100
:WIDTH 100})]))

;; ### Combining a few things together
;;
;; The following is inspired by the example at Plotnine's [main page](https://plotnine.readthedocs.io/en/stable/).

(def mtcars
(-> "/tmp/mtcars.csv"
(tc/dataset {:key-fn keyword})))

(let [pallete (->> :accent
color/palette
(mapv color/format-hex))]
(-> mtcars
(tc/group-by :gear {:result-type :as-map})
(->> (sort-by key)
(map-indexed
(fn [i [group-name ds]]
(-> ds
(stats/add-predictions :mpg [:wt]
{:model-type :smile.regression/ordinary-least-square})
(vis/hanami-layers {:TITLE (str "grear=" group-name)}
[(vis/hanami-plot nil
ht/point-chart
{:X :wt
:Y :mpg
:MSIZE 200
:MCOLOR (pallete i)
:HEIGHT 200
:WIDTH 200})
(vis/hanami-plot nil
ht/line-chart
{:X :wt
:Y :mpg-prediction
:MSIZE 5
:MCOLOR (pallete i)
:YTITLE :mpg})]
))))
(vis/hanami-hconcat nil {}))))

:bye

0 comments on commit 383e68a

Please sign in to comment.