Liking cljdoc? Tell your friends :D

com.blockether.imaging.plot

A small, opinionated plotting DSL over com.blockether.imaging/plot.

The renderer lives in the Rust cdylib (native/imaging-c/src/plot.rs, drawn with tiny-skia and text-shaped through usvg), so plotting needs NO java.desktop, no headless AWT and no fonts on the host — four Noto faces are embedded in the library.

Everything here is DATA: a figure is a map, a panel is a map, a series is a map. This namespace only builds those maps (and hands them to the renderer), so anything the DSL doesn't wrap yet you can still express by assoc'ing the raw key — unknown keys are passed straight through to the renderer.

(require '[com.blockether.imaging.plot :as plot])

(plot/save! "cpu.png"
  (plot/figure {:title "CPU" :theme :dark :width 900 :height 400}
    (plot/lines {:x-label "minute" :y-label "%"}
      {:name "user" :x (range 60) :y user-samples}
      {:name "sys"  :x (range 60) :y sys-samples})))

Panel constructors: lines areas bars hbars stacked-bars scatter steps histogram pie donut heatmap. Each takes an optional option map first, then series maps (or plain sequences of numbers). figure composes panels into a grid; a bare panel is itself a valid figure.

A small, opinionated plotting DSL over `com.blockether.imaging/plot`.

The renderer lives in the Rust cdylib (`native/imaging-c/src/plot.rs`, drawn
with tiny-skia and text-shaped through usvg), so plotting needs NO
`java.desktop`, no headless AWT and no fonts on the host — four Noto faces are
embedded in the library.

Everything here is DATA: a figure is a map, a panel is a map, a series is a
map. This namespace only builds those maps (and hands them to the renderer),
so anything the DSL doesn't wrap yet you can still express by assoc'ing the
raw key — unknown keys are passed straight through to the renderer.

```clojure
(require '[com.blockether.imaging.plot :as plot])

(plot/save! "cpu.png"
  (plot/figure {:title "CPU" :theme :dark :width 900 :height 400}
    (plot/lines {:x-label "minute" :y-label "%"}
      {:name "user" :x (range 60) :y user-samples}
      {:name "sys"  :x (range 60) :y sys-samples})))
```

Panel constructors: `lines` `areas` `bars` `hbars` `stacked-bars` `scatter`
`steps` `histogram` `pie` `donut` `heatmap`. Each takes an optional option map
first, then series maps (or plain sequences of numbers). `figure` composes
panels into a grid; a bare panel is itself a valid figure.
raw docstring

areasclj

(areas & args)

Filled area panel (add :stack true to stack the series).

Filled area panel (add `:stack true` to stack the series).
sourceraw docstring

barsclj

(bars & args)

Vertical bar panel. :labels on the panel (or :x on a series) names the categories; :bar-width 0-1, :bar-radius px, :labels-on true prints the value above each bar.

Vertical bar panel. `:labels` on the panel (or `:x` on a series) names the
categories; `:bar-width` 0-1, `:bar-radius` px, `:labels-on true` prints the
value above each bar.
sourceraw docstring

bytesclj

(bytes fig)
(bytes fig {:keys [format quality] :or {format "png" quality 0} :as opts})

Render straight to encoded image bytes (PNG by default). (bytes fig {:format "webp" :quality 90})

Render straight to encoded image bytes (PNG by default).
`(bytes fig {:format "webp" :quality 90})`
sourceraw docstring

donutclj

(donut & args)

Pie with a hole (:hole 0-1, :center-label in the middle).

Pie with a hole (`:hole` 0-1, `:center-label` in the middle).
sourceraw docstring

figureclj

(figure opts & panels)

Compose panels into one figure spec.

Figure options: :width :height (px), :title :subtitle :caption, :theme ∈ #{:light :dark :night}, :background, :palette (vector of colours), :font-family :font-size, :legend (true/false/"top"/ "right"), :grid, :rows/:cols for the panel grid.

Compose panels into one figure spec.

Figure options: `:width` `:height` (px), `:title` `:subtitle` `:caption`,
`:theme` ∈ #{:light :dark :night}, `:background`, `:palette` (vector of
colours), `:font-family` `:font-size`, `:legend` (`true`/`false`/`"top"`/
`"right"`), `:grid`, `:rows`/`:cols` for the panel grid.
sourceraw docstring

hbarsclj

(hbars & args)

Horizontal bar panel — the readable choice when category names are long.

Horizontal bar panel — the readable choice when category names are long.
sourceraw docstring

heatmapclj

(heatmap & args)

Matrix heat map: a series :z of rows, :colormap ∈ #{"viridis" "magma" "inferno" "plasma" "coolwarm" "blues" "reds" "greys"}.

Matrix heat map: a series `:z` of rows, `:colormap` ∈ #{"viridis" "magma"
"inferno" "plasma" "coolwarm" "blues" "reds" "greys"}.
sourceraw docstring

histogramclj

(histogram & args)

Histogram of raw samples; :bins (default auto).

Histogram of raw samples; `:bins` (default auto).
sourceraw docstring

linesclj

(lines & args)

Line panel. (lines {:y-label "ms"} {:name "p50" :x xs :y ys} …). Series keys: :name :x :y :color :dash :width :marker :marker-size :fill-alpha.

Line panel. `(lines {:y-label "ms"} {:name "p50" :x xs :y ys} …)`.
Series keys: `:name` `:x` `:y` `:color` `:dash` `:width` `:marker`
`:marker-size` `:fill-alpha`.
sourceraw docstring

pieclj

(pie & args)

Pie chart from :values + :labels (:labels-on prints percentages).

Pie chart from `:values` + `:labels` (`:labels-on` prints percentages).
sourceraw docstring

renderclj

(render fig)
(render fig opts)

Render a figure (or a bare panel) to an Img handle.

Render a figure (or a bare panel) to an `Img` handle.
sourceraw docstring

save!clj

(save! path fig)
(save! path fig opts)

Render a figure and write it to path; the format comes from the extension. Returns path.

Render a figure and write it to `path`; the format comes from the extension.
Returns `path`.
sourceraw docstring

scatterclj

(scatter & args)

Scatter panel. Series :marker ∈ #{"circle" "square" "diamond" "triangle" "cross"}, :marker-size px, :z a per-point weight.

Scatter panel. Series `:marker` ∈ #{"circle" "square" "diamond"
"triangle" "cross"}, `:marker-size` px, `:z` a per-point weight.
sourceraw docstring

stacked-barsclj

(stacked-bars & args)

Bar panel with the series stacked instead of grouped.

Bar panel with the series stacked instead of grouped.
sourceraw docstring

stepsclj

(steps & args)

Step / staircase panel — the honest shape for sampled counters.

Step / staircase panel — the honest shape for sampled counters.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close