Skip to content

Commit

Permalink
python plotting: simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
daslu committed Jul 24, 2024
1 parent 2c0c95c commit 05a5cd9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions projects/datavis/python/plotting/notebooks/index.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@

;; ## Implementation

(defn- svg-file->kindly
"Takes an SVG file path and turns it into
a Clojure value that can be displayed in Kindly-compatible tools:
a vector holding the SVG string, annotated with the relevant metadata."
[path]
(-> path
slurp
vector
(with-meta {:kindly/kind :kind/html})))

(defmacro with-pyplot
"Takes forms with mathplotlib.pyplot and returns a showable (SVG) plot.
E.g.:
Expand All @@ -48,7 +38,12 @@
~(cons 'do forms)
(py. agg-canvas# "draw")
(matplotlib.pyplot/savefig path#)
(svg-file->kindly path#)))
;; Take the SVG file path and turn it into
;; a Clojure value that can be displayed in Kindly-compatible tools.
(-> path#
slurp
vector
(with-meta {:kindly/kind :kind/html}))))

(defn pyplot
"Takes a function plotting using mathplotlib.pyplot, and returns a showable (SVG) plot.
Expand Down

0 comments on commit 05a5cd9

Please sign in to comment.