12  Limits

What cljplot2 doesn’t do, and the nearest way around it.

(ns reference.limits
  (:require [cljplot2.chart :as chart]
            [cljplot2.core :as plot]
            [notebook-utils :as nu]))

12.1 Output

  • Static raster images only (BufferedImage, a clojure2d raster canvas) - no interactivity, no SVG or PDF; plot/save writes the formats Java’s ImageIO knows (png, jpg, bmp, gif, tiff …; Render chapter).

12.2 Layout

  • Legends sit right of the panels; there is no placement option. A legend can go elsewhere as its own plot: :legend-only true in an :arrange cell (and :legend false on the plot beside it).

  • No subtitle or caption: write them with the text chart in panel units, or as a title of an :arrange.

  • :margins need a single panel (no facets, :arrange or :custom-grid); :aspect :iso and :flip need the generated grid; free or sliced facet scales don’t combine with explicit domains or :aspect :iso.

A caption written by a text chart, a legend moved below by :legend-only:

(def rows (for [[i g] (map-indexed vector ["a" "b" "c"]) x (range 12)]
            {:g g :x x :y (+ (* x (inc i)) (mod (* x 7) 5))}))
g x y
a 0 0
a 1 3
a 2 6
a 3 4
a 4 7
a 5 5
a 6 8
a 7 11
a 8 9
a 9 12
a 10 10
a 11 13
b 0 0
b 1 4
b 2 8
b 3 7
b 4 11
b 5 10
b 6 14
b 7 18
b 8 17
b 9 21
b 10 20
b 11 24
c 0 0
c 1 5
c 2 10
c 3 10
c 4 15
c 5 15
c 6 20
c 7 25
c 8 25
c 9 30
c 10 30
c 11 35
(plot/render-image (plot/arrange [{:data rows
                                   :mapping {:x :x :y :y :color :g}
                                   :charts [(chart/line)
                                            (chart/text {:x [:panel 1.0] :y [:panel 0.02] :anchor [:right :bottom]
                                                         :text "caption: synthetic data" :size 9 :extent false})]
                                   :legend false}
                                  {:data rows
                                   :mapping {:x :x :y :y :color :g}
                                   :charts [(chart/line)]
                                   :legend-only true}]
                                 {:rows 2 :heights [6 1]})
                   {:width 600 :height 450})

12.3 Coordinates

  • Polar coordinates only with the charts declaring them (Scales, axes and coordinates chapter); no polar :aspect :iso, :margins or :custom-grid.

  • 3D charts (cloud, surface) only with other 3D charts, without :flip, :aspect :iso, :margins, polar coordinates or free facet scales.

  • No map projections or geographic shapes.

12.4 Data

  • Data is rows (maps) or columns (equal-length sequences); other tables are converted by the caller.
  • Dates are java.time values; date strings stay levels.
source: notebooks/reference/limits.clj