added experiments with geom

This commit is contained in:
didier amyot committed 2017-12-07 07:37:28 -05:00
1 parent 0dc1740eba
commit 551594ce63
4 files changed
+163 -14

No files matched your search

+142
View File
@@ -0,0 +1,142 @@
{
"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": [
"<?xml version=\"1.0\"?>\n",
"<svg height=\"600\" version=\"1.1\" width=\"985\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\"><g><g stroke-dasharray=\"1 1\" stroke=\"#caa\"><line x1=\"170.90\" x2=\"170.90\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"241.62\" x2=\"241.62\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"291.80\" x2=\"291.80\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"330.72\" x2=\"330.72\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"362.52\" x2=\"362.52\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"389.40\" x2=\"389.40\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"412.70\" x2=\"412.70\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"433.24\" x2=\"433.24\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"572.51\" x2=\"572.51\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"643.24\" x2=\"643.24\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"693.41\" x2=\"693.41\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"732.33\" x2=\"732.33\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"764.13\" x2=\"764.13\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"791.02\" x2=\"791.02\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"814.31\" x2=\"814.31\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"834.85\" x2=\"834.85\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"974.13\" x2=\"974.13\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"50.00\" x2=\"50.00\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"451.62\" x2=\"451.62\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"853.23\" x2=\"853.23\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"524.00\" y2=\"524.00\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"470.95\" y2=\"470.95\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"417.90\" y2=\"417.90\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"364.84\" y2=\"364.84\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"311.79\" y2=\"311.79\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"258.74\" y2=\"258.74\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"205.69\" y2=\"205.69\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"152.63\" y2=\"152.63\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"99.58\" y2=\"99.58\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"46.53\" y2=\"46.53\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"497.48\" y2=\"497.48\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"444.42\" y2=\"444.42\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"391.37\" y2=\"391.37\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"338.32\" y2=\"338.32\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"285.27\" y2=\"285.27\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"232.21\" y2=\"232.21\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"179.16\" y2=\"179.16\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"126.11\" y2=\"126.11\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"73.05\" y2=\"73.05\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"20.00\" y2=\"20.00\" /></g><g fill=\"#0af\" stroke=\"none\"><circle cx=\"170.90\" cy=\"543.03\" r=\"3\" /><circle cx=\"291.80\" cy=\"539.92\" r=\"3\" /><circle cx=\"362.52\" cy=\"537.54\" r=\"3\" /><circle cx=\"412.70\" cy=\"535.52\" r=\"3\" /><circle cx=\"451.62\" cy=\"533.75\" r=\"3\" /><circle cx=\"483.42\" cy=\"532.15\" r=\"3\" /><circle cx=\"510.30\" cy=\"530.68\" r=\"3\" /><circle cx=\"533.59\" cy=\"529.31\" r=\"3\" /><circle cx=\"554.14\" cy=\"528.02\" r=\"3\" /><circle cx=\"572.51\" cy=\"526.80\" r=\"3\" /><circle cx=\"589.14\" cy=\"525.65\" r=\"3\" /><circle cx=\"604.31\" cy=\"524.54\" r=\"3\" /><circle cx=\"618.28\" cy=\"523.48\" r=\"3\" /><circle cx=\"631.20\" cy=\"522.46\" r=\"3\" /><circle cx=\"643.24\" cy=\"521.47\" r=\"3\" /><circle cx=\"654.49\" cy=\"520.52\" r=\"3\" /><circle cx=\"665.07\" cy=\"519.60\" r=\"3\" /><circle cx=\"675.04\" cy=\"518.70\" r=\"3\" /><circle cx=\"684.47\" cy=\"517.83\" r=\"3\" /><circle cx=\"693.41\" cy=\"516.98\" r=\"3\" /><circle cx=\"701.92\" cy=\"516.15\" r=\"3\" /><circle cx=\"710.04\" cy=\"515.34\" r=\"3\" /><circle cx=\"717.79\" cy=\"514.55\" r=\"3\" /><circle cx=\"725.21\" cy=\"513.77\" r=\"3\" /><circle cx=\"732.33\" cy=\"513.02\" r=\"3\" /><circle cx=\"739.17\" cy=\"512.27\" r=\"3\" /><circle cx=\"745.76\" cy=\"511.54\" r=\"3\" /><circle cx=\"752.10\" cy=\"510.83\" r=\"3\" /><circle cx=\"758.22\" cy=\"510.13\" r=\"3\" /><circle cx=\"764.13\" cy=\"509.44\" r=\"3\" /><circle cx=\"769.85\" cy=\"508.76\" r=\"3\" /><circle cx=\"775.39\" cy=\"508.09\" r=\"3\" /><circle cx=\"780.76\" cy=\"507.43\" r=\"3\" /><circle cx=\"785.96\" cy=\"506.78\" r=\"3\" /><circle cx=\"791.02\" cy=\"506.14\" r=\"3\" /><circle cx=\"795.93\" cy=\"505.51\" r=\"3\" /><circle cx=\"800.71\" cy=\"504.89\" r=\"3\" /><circle cx=\"805.36\" cy=\"504.28\" r=\"3\" /><circle cx=\"809.90\" cy=\"503.68\" r=\"3\" /><circle cx=\"814.31\" cy=\"503.08\" r=\"3\" /><circle cx=\"818.62\" cy=\"502.49\" r=\"3\" /><circle cx=\"822.82\" cy=\"501.91\" r=\"3\" /><circle cx=\"826.93\" cy=\"501.33\" r=\"3\" /><circle cx=\"830.93\" cy=\"500.76\" r=\"3\" /><circle cx=\"834.85\" cy=\"500.20\" r=\"3\" /><circle cx=\"838.69\" cy=\"499.64\" r=\"3\" /><circle cx=\"842.44\" cy=\"499.09\" r=\"3\" /><circle cx=\"846.11\" cy=\"498.55\" r=\"3\" /><circle cx=\"849.71\" cy=\"498.01\" r=\"3\" /><circle cx=Line truncated
]
},
"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": [
"<?xml version=\"1.0\"?>\n",
"<svg height=\"600\" version=\"1.1\" width=\"985\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\"><g><g stroke-dasharray=\"1 1\" stroke=\"#caa\"><line x1=\"170.90\" x2=\"170.90\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"241.62\" x2=\"241.62\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"291.80\" x2=\"291.80\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"330.72\" x2=\"330.72\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"362.52\" x2=\"362.52\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"389.40\" x2=\"389.40\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"412.70\" x2=\"412.70\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"433.24\" x2=\"433.24\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"572.51\" x2=\"572.51\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"643.24\" x2=\"643.24\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"693.41\" x2=\"693.41\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"732.33\" x2=\"732.33\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"764.13\" x2=\"764.13\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"791.02\" x2=\"791.02\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"814.31\" x2=\"814.31\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"834.85\" x2=\"834.85\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"974.13\" x2=\"974.13\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"50.00\" x2=\"50.00\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"451.62\" x2=\"451.62\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"853.23\" x2=\"853.23\" y1=\"550.00\" y2=\"20.00\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"496.89\" y2=\"496.89\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"465.83\" y2=\"465.83\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"443.79\" y2=\"443.79\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"426.69\" y2=\"426.69\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"412.72\" y2=\"412.72\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"400.91\" y2=\"400.91\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"390.68\" y2=\"390.68\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"381.66\" y2=\"381.66\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"320.48\" y2=\"320.48\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"289.42\" y2=\"289.42\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"267.38\" y2=\"267.38\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"250.28\" y2=\"250.28\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"236.31\" y2=\"236.31\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"224.50\" y2=\"224.50\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"214.27\" y2=\"214.27\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"205.25\" y2=\"205.25\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"144.07\" y2=\"144.07\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"113.00\" y2=\"113.00\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"90.96\" y2=\"90.96\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"73.87\" y2=\"73.87\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"59.90\" y2=\"59.90\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"48.09\" y2=\"48.09\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"37.86\" y2=\"37.86\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"28.83\" y2=\"28.83\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"550.00\" y2=\"550.00\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"373.59\" y2=\"373.59\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"197.17\" y2=\"197.17\" /><line x1=\"50.00\" x2=\"975.00\" y1=\"20.76\" y2=\"20.76\" /></g><g fill=\"#0af\" stroke=\"none\"><circle cx=\"170.90\" cy=\"347.03\" r=\"3\" /><circle cx=\"291.80\" cy=\"320.48\" r=\"3\" /><circle cx=\"362.52\" cy=\"304.95\" r=\"3\" /><circle cx=\"412.70\" cy=\"293.93\" r=\"3\" /><circle cx=\"451.62\" cy=\"285.38\" r=\"3\" /><circle cx=\"483.42\" cy=\"278.40\" r=\"3\" /><circle cx=\"510.30\" cy=\"272.49\" r=\"3\" /><circle cx=\"533.59\" cy=\"267.38\" r=\"3\" /><circle cx=\"554.14\" cy=\"262.86\" r=\"3\" /><circle cx=\"572.51\" cy=\"258.83\" r=\"3\" /><circle cx=\"589.14\" cy=\"255.18\" r=\"3\" /><circle cx=\"604.31\" cy=\"251.84\" r=\"3\" /><circle cx=\"618.28\" cy=\"248.78\" r=\"3\" /><circle cx=\"631.20\" cy=\"245.94\" r=\"3\" /><circle cx=\"643.24\" cy=\"243.30\" r=\"3\" /><circle cx=\"654.49\" cy=\"240.82\" r=\"3\" /><circle cx=\"665.07\" cy=\"238.50\" r=\"3\" /><circle cx=\"675.04\" cy=\"236.31\" r=\"3\" /><circle cx=\"684.47\" cy=\"234.24\" r=\"3\" /><circle cx=\"693.41\" cy=\"232.28\" r=\"3\" /><circle cx=\"701.92\" cy=\"230.41\" r=\"3\" /><circle cx=\"710.04\" cy=\"228.62\" r=\"3\" /><circle cx=\"717.79\" cy=\"226.92\" r=\"3\" /><circle cx=\"725.21\" cy=\"225.29\" r=\"3\" /><circle cx=\"732.33\" cy=\"223.73\" r=\"3\" /><circle cx=\"739.17\" cy=\"222.23\" r=\"3\" /><circle cx=\"745.76\" cy=\"220.78\" r=\"3\" /><circle cx=\"752.10\" cy=\"219.39\" r=\"3\" /><circle cx=\"758.22\" cy=\"218.04\" r=\"3\" /><circle cx=\"764.13\" cy=\"216.74\" r=\"3\" /><circle cx=\"769.85\" cy=\"215.49\" r=\"3\" /><circle cx=\"775.39\" cy=\"214.27\" r=\"3\" /><circle cx=\"780.76\" cy=\"213.09\" r=\"3\" /><circle cx=\"785.96\" cy=\"211.95\" r=\"3\" /><circle cx=\"791.02\" cy=\"210.84\" r=\"3\" /><circle cx=\"795.93\" cy=\"209.76\" r=\"3\" /><circle cx=\"800.71\" cy=\"208.71\" r=\"3\" /><circle cx=\"805.36\" cy=\"207.69\" r=\"3\" /><circle cx=\"809.90Line truncated
]
},
"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
}