7 Python (experimental 🛠)
author: Daniel Slutsky
ns noj-book.python
(:require [libpython-clj2.require :refer [require-python]]
(:refer [py. py.. py.-] :as py]
[libpython-clj2.python :as vis.python]
[scicloj.noj.v1.vis.python :as tc]
[tablecloth.api :as tcc])) [tablecloth.column.api
7.1 Using Python visualizations
Noj offers methods to include Python plots in Kindly visualizations: the vis.python/with-pyplot
macro and the vis.python/pyplot
function.
They are based on the Parens for Pyplot blog post at Squid’s blog.
:as np]
(require-python '[numpy :as np.random]
'[numpy.random 'matplotlib.pyplot
:as sns]
'[seaborn 'json)
:ok
def sine-data
(-> {:x (range 0 (* 3 np/pi) 0.1)}
(
tc/dataset:y #(tcc/sin (:x %))))) (tc/add-column
(vis.python/with-pyplot
(matplotlib.pyplot/plot:x sine-data)
(:y sine-data))) (
(vis.python/pyplot
#(matplotlib.pyplot/plot:x sine-data)
(:y sine-data))) (
https://seaborn.pydata.org/tutorial/introduction
let [tips (sns/load_dataset "tips")]
(
(sns/set_theme)
(vis.python/pyplot:data tips
#(sns/relplot :x "total_bill"
:y "tip"
:col "time"
:hue "smoker"
:style "smoker"
:size "size")))
:bye
:bye
source: notebooks/noj_book/python.clj