{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"(require '[thi.ng.geom.viz.core :as viz]\n",
" '[thi.ng.geom.svg.core :as svg]\n",
" '[thi.ng.geom.core.vector :as v]\n",
" '[thi.ng.color.core :as col]\n",
" '[thi.ng.math.core :as m :refer [PI TWO_PI]]\n",
" '[clojupyter.misc.display :as display])"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"#'user/spec"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"(defn export-viz\n",
" [spec]\n",
" (->> spec\n",
" (viz/svg-plot2d-cartesian)\n",
" (svg/svg {:width 985 :height 600})\n",
" (svg/serialize)))\n",
"\n",
"(def spec\n",
" {:x-axis (viz/log-axis\n",
" {:domain [1 201]\n",
" :range [50 (- 985 10)]\n",
" :pos 550})\n",
" :y-axis (viz/linear-axis\n",
" {:domain [0.1 100]\n",
" :range [550 20]\n",
" :major 10\n",
" :minor 5\n",
" :pos 50\n",
" :label-dist 15\n",
" :label-style {:text-anchor \"end\"}})\n",
" :grid {:attribs {:stroke \"#caa\"}\n",
" :minor-x true\n",
" :minor-y true}\n",
" :data [{:values (map (juxt identity #(Math/sqrt %)) (range 0 200 2))\n",
" :attribs {:fill \"#0af\" :stroke \"none\"}\n",
" :layout viz/svg-scatter-plot}\n",
" {:values (map (juxt identity #(m/random %)) (range 0 200 2))\n",
" :attribs {:fill \"none\" :stroke \"#f60\"}\n",
" :shape (viz/svg-triangle-down 6)\n",
" :layout viz/svg-scatter-plot}]})"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
""
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(-> spec\n",
" (export-viz)\n",
" (display/make-html))"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
""
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(-> spec\n",
" (assoc :y-axis (viz/log-axis\n",
" {:domain [0.1 101]\n",
" :range [550 20]\n",
" :pos 50\n",
" :label-dist 15\n",
" :label-style {:text-anchor \"end\"}}))\n",
" (export-viz)\n",
" (display/make-html))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Lein-Clojure",
"language": "clojure",
"name": "lein-clojure"
},
"language_info": {
"file_extension": ".clj",
"mimetype": "text/x-clojure",
"name": "clojure",
"version": "1.9.0-RC1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}