Skip to content
generatemePublic

About

Charting library for Clojure

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

209 Commits

Folders and files

Repository files navigation

cljplot2 logo: the word cljplot2 drawn as a scatter plot with density margins

cljplot2

A plotting library for Clojure: plots are plain maps of data, mappings and charts, built and rendered by functions.

  • Pure JVM: renders BufferedImages and image files, no browser or JavaScript.
  • Built on fastmath (statistics, distributions, layouts), wadogo (scales), clojure2d (drawing, colours) and malli (validated options with readable errors).
  • Charts: scatter, line, bar, histogram, density, box, violin, ribbon, smooth, heatmaps, 2D fields and contours, Q-Q / P-P, treemap, sunburst, circle packing, waffle, Venn, networks, dendrograms, chord, arc and sankey diagrams, and more; facets, polar coordinates, margins, multiplots.

Install

There's no release yet. Use a git coordinate in deps.edn:

io.github.generateme/cljplot2 {:git/sha "2ae278d772277fc9341e287793d41c83af697698"}

cljplot2 depends on SNAPSHOT versions: fastmath 3.0.0-alpha10-SNAPSHOT is on Clojars; clojure2d 1.5.0-alpha3-SNAPSHOT and wadogo 1.1.0-alpha2-SNAPSHOT aren't yet - install them locally from their repositories.

Example

(require '[cljplot2.core :as plot]
         '[cljplot2.chart :as chart]
         '[clojure2d.core :as c2d])

(def data
  (for [series ["sin" "cos"]
        x (range 0 6.3 0.1)]
    {:x x :y ((if (= series "sin") Math/sin Math/cos) x) :series series}))

(-> {:data data
     :mapping {:x :x :y :y :color :series}
     :charts [(chart/line) (chart/scatter)]
     :labels {:title "Hello, cljplot2"}}
    (plot/render-image {:width 600 :height 350})
    (c2d/save "example.png"))

the example: sin and cos lines with points, coloured by series

Documentation

The book: https://generateme.github.io/cljplot2/ - use cases after the R Graph Gallery and data-to-viz:

Galleries (in progress): cljplot extras - the examples of the original cljplot (Q-Q / P-P, ACF, vector fields, complex functions, ...); lattice and Vega galleries are planned.

Every public function has a docstring; namespaces: cljplot2.core (build, render, builders), cljplot2.chart (charts), cljplot2.data.* (row and layout functions).

Development

clojure -M:test     # tests
clojure -M:check    # reflection and boxed-math warnings
clojure -M:demo     # demo images to results/ (and the logo to img/)
clojure -M:clay     # the book into docs/

License

Copyright © GenerateMe and contributors.

Developed with the support of an LLM (Anthropic's Claude) - design, code, tests and documentation were reviewed by the author.

Distributed under the Eclipse Public License 2.0.

The bundled font, DejaVu Sans Mono (resources/fonts/), keeps its own licence: Bitstream Vera Fonts licence, DejaVu changes in the public domain - see LICENSE-DejaVu.txt.

About

Charting library for Clojure

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages