Dynamic var for thread-local config overrides. Bind to a map to override any config keys for the current thread. (binding [defaults/config {:theme {:bg "#FFF"}}] ...)
Dynamic var for thread-local config overrides.
Bind to a map to override any config keys for the current thread.
(binding [defaults/*config* {:theme {:bg "#FFF"}}] ...)Per-aesthetic semantic properties. Single source of truth for the set of mapping keys that can reference dataset columns. :numeric? marks aesthetics whose column values, when present, are numeric -- those are the keys eligible for finite-value filtering at plan time.
Per-aesthetic semantic properties. Single source of truth for the set of mapping keys that can reference dataset columns. :numeric? marks aesthetics whose column values, when present, are numeric -- those are the keys eligible for finite-value filtering at plan time.
(c2d->rgba color)Convert a clojure2d color (Vec4, 0-255 channels) to [r g b a] in 0-1 range.
Convert a clojure2d color (Vec4, 0-255 channels) to [r g b a] in 0-1 range.
(color-for categories val)(color-for categories val palette)Look up the color for a categorical value from the palette. Returns [r g b a] in 0-1 range. palette can be: nil (default), a keyword (any clojure2d palette name), a vector of hex strings, or a map of {category-value color}.
Map lookup is tolerant of string/keyword mismatch: {:setosa "#F00"} matches both :setosa and "setosa" data values.
For keyword/vector palettes, the i-th category gets the i-th
palette entry (wrapping modulo the palette size). This preserves
the authorial ordering of designed-categorical palettes like
:set1, :dark2, :tableau-10. If you want a continuous color ramp
(viridis, inferno, etc.) for a numeric column, use the dedicated
:color-scale option instead -- that's the canonical gradient
path and interpolates the full color range smoothly.
Look up the color for a categorical value from the palette.
Returns [r g b a] in 0-1 range.
palette can be: nil (default), a keyword (any clojure2d palette name),
a vector of hex strings, or a map of {category-value color}.
Map lookup is tolerant of string/keyword mismatch: {:setosa "#F00"}
matches both :setosa and "setosa" data values.
For keyword/vector palettes, the i-th category gets the i-th
palette entry (wrapping modulo the palette size). This preserves
the authorial ordering of designed-categorical palettes like
:set1, :dark2, :tableau-10. If you want a continuous color ramp
(viridis, inferno, etc.) for a numeric column, use the dedicated
`:color-scale` option instead -- that's the canonical gradient
path and interpolates the full color range smoothly.Set of keywords that can reference dataset columns in mappings.
Set of keywords that can reference dataset columns in mappings.
(config)Return the effective resolved configuration as a map. Deep-merges: library defaults < plotje.edn < set-config! < config. Nested maps (e.g. :theme) are merged recursively. Useful for inspecting which values are in effect.
Return the effective resolved configuration as a map. Deep-merges: library defaults < plotje.edn < set-config! < *config*. Nested maps (e.g. :theme) are merged recursively. Useful for inspecting which values are in effect.
Documentation metadata for configuration keys. Each entry maps a key to [category description].
Documentation metadata for configuration keys. Each entry maps a key to [category description].
Default categorical palette name (clojure2d palette keyword).
Default categorical palette name (clojure2d palette keyword).
In-code fallback for keys not present in the EDN resource. The EDN
file (resources/plotje-defaults.edn) is the canonical source;
this map is consulted only when the EDN load fails or as a secondary
lookup in (or cfg defaults) patterns in stat/layout code.
In-code fallback for keys not present in the EDN resource. The EDN file (`resources/plotje-defaults.edn`) is the canonical source; this map is consulted only when the EDN load fails or as a secondary lookup in `(or cfg defaults)` patterns in stat/layout code.
Diverging gradient function (RdBu). Takes t in [0,1], returns [r g b a] 0-1.
Diverging gradient function (RdBu). Takes t in [0,1], returns [r g b a] 0-1.
(fmt-category-label v)Format a category value (keyword, string, number, etc.) for display. Used for axis tick labels, legend entries, facet strip labels, and any other user-visible category text.
Formats by the same rule as fmt-name, so a keyword category reads as
words: :not-applicable becomes not applicable. Hyphenated keyword
categories are common and are nearly always meant as words, which is
what makes the rule worth applying to data as well as to names.
Two keyword categories differing only by separator -- :a-b and :a_b --
therefore format alike. On a categorical axis that combines them, since
impl/stat.clj maps the column through this function before grouping;
format-category-column there warns when it happens. Convert such a
column to strings to keep the values apart.
Format a category value (keyword, string, number, etc.) for display. Used for axis tick labels, legend entries, facet strip labels, and any other user-visible category text. Formats by the same rule as `fmt-name`, so a keyword category reads as words: :not-applicable becomes not applicable. Hyphenated keyword categories are common and are nearly always meant as words, which is what makes the rule worth applying to data as well as to names. Two keyword categories differing only by separator -- :a-b and :a_b -- therefore format alike. On a categorical axis that combines them, since `impl/stat.clj` maps the column through this function before grouping; `format-category-column` there warns when it happens. Convert such a column to strings to keep the values apart.
(fmt-name k)Format a column name for display: :sepal-length becomes sepal length. Hyphens and underscores turn into spaces in a keyword or a symbol, neither of which can hold a space, so a separator in one stands in for a word break. A string is left as written -- a string can hold a space, so a hyphen in one was chosen rather than substituted, as in Cost-Benefit Ratio. Any other name -- a dataset built without column names gets integer ones -- formats as its printed form, so auto-labelling does not crash on it.
Format a column name for display: :sepal-length becomes sepal length. Hyphens and underscores turn into spaces in a keyword or a symbol, neither of which can hold a space, so a separator in one stands in for a word break. A string is left as written -- a string can hold a space, so a hyphen in one was chosen rather than substituted, as in Cost-Benefit Ratio. Any other name -- a dataset built without column names gets integer ones -- formats as its printed form, so auto-labelling does not crash on it.
(fmt-value-label v separator)Format a data value for display as text on a plot, grouping the digits of
a number when a separator is configured. Non-numeric values format as
fmt-category-label does.
Format a data value for display as text on a plot, grouping the digits of a number when a `separator` is configured. Non-numeric values format as `fmt-category-label` does.
Default gradient function (dark blue → light blue, matching ggplot2). Takes t in [0,1], returns [r g b a] 0-1.
Default gradient function (dark blue → light blue, matching ggplot2). Takes t in [0,1], returns [r g b a] 0-1.
Set of keywords that resolve to a continuous gradient rather than a
categorical palette. Users who pass these to :palette almost always
meant :color-scale with a numeric color column. plan/warn-palette-wrap!
fires a warning when it sees one of these on the :palette slot.
Set of keywords that resolve to a continuous gradient rather than a categorical palette. Users who pass these to `:palette` almost always meant `:color-scale` with a numeric color column. `plan/warn-palette-wrap!` fires a warning when it sees one of these on the `:palette` slot.
(group-digits s separator)Insert separator between three-digit groups in the integer part of an
already-formatted number string: 462389 with a comma gives 462,389.
A leading sign, a fractional part, and any exponent are left alone.
Returns s unchanged when separator is nil or empty, or when s does
not begin with digits. Only nil and the empty string count as absent: a
single space is a valid separator, the convention in much of Europe.
Insert `separator` between three-digit groups in the integer part of an already-formatted number string: 462389 with a comma gives 462,389. A leading sign, a fractional part, and any exponent are left alone. Returns `s` unchanged when `separator` is nil or empty, or when `s` does not begin with digits. Only nil and the empty string count as absent: a single space is a valid separator, the convention in much of Europe.
(hex->rgba color)Convert any color representation to [r g b a] in 0-1 range. Accepts hex strings (#RGB, #RRGGBB, #RRGGBBAA, or without #), named color strings ("red", "steelblue"), keywords (:red, :darkblue), or any value that clojure2d.color/to-color understands.
Convert any color representation to [r g b a] in 0-1 range.
Accepts hex strings (#RGB, #RRGGBB, #RRGGBBAA, or without #),
named color strings ("red", "steelblue"), keywords (:red, :darkblue),
or any value that clojure2d.color/to-color understands.Side length of legend color swatches (square, in pixels).
Side length of legend color swatches (square, in pixels).
(normalize-continuous scale-type v vmin vmax midpoint)Remap a value v from [vmin, vmax] to [0,1] using a scale-type aware transform. :linear (default) uses normalize-midpoint with the optional midpoint. :log uses log10 endpoints; midpoint is ignored under :log.
Remap a value v from [vmin, vmax] to [0,1] using a scale-type aware transform. :linear (default) uses normalize-midpoint with the optional midpoint. :log uses log10 endpoints; midpoint is ignored under :log.
(normalize-midpoint v vmin vmax midpoint)Remap a value v from [vmin, vmax] to [0,1] with optional midpoint. Without midpoint: linear (v-vmin)/(vmax-vmin). With midpoint: values below midpoint → [0, 0.5], above → [0.5, 1.0].
Remap a value v from [vmin, vmax] to [0,1] with optional midpoint. Without midpoint: linear (v-vmin)/(vmax-vmin). With midpoint: values below midpoint → [0, 0.5], above → [0.5, 1.0].
Aesthetics whose column values are numeric -- subject to finite-value filtering. Derived from aesthetic-registry.
Aesthetics whose column values are numeric -- subject to finite-value filtering. Derived from aesthetic-registry.
Documentation for plot-level option keys. These are accepted by pj/options, pj/plan, and pj/plot but are inherently per-plot (text content or nested config override). Each entry maps a key to [category description].
Documentation for plot-level option keys. These are accepted by pj/options, pj/plan, and pj/plot but are inherently per-plot (text content or nested config override). Each entry maps a key to [category description].
(resolve-config plot-opts)Resolve config with plot options deep-merged on top of the precedence chain.
Plot options have the highest priority. Any key from config-key-docs
passed directly in plot-opts is forwarded to the resolved cfg. Nested
maps (:theme) are merged recursively. The :config key is a deep-merge
escape hatch for arbitrary overrides.
Resolve config with plot options deep-merged on top of the precedence chain. Plot options have the highest priority. Any key from `config-key-docs` passed directly in plot-opts is forwarded to the resolved cfg. Nested maps (:theme) are merged recursively. The `:config` key is a deep-merge escape hatch for arbitrary overrides.
(resolve-gradient-fn color-scale)Resolve a :color-scale option to a gradient function t→[r g b a] (0-1 range). nil or :sequential → dark blue to light blue (ggplot2 default). :diverging → RdBu. keyword → clojure2d gradient name (:inferno, :viridis/plasma, etc.). map {:low hex :mid hex :high hex} → custom 3-stop gradient. function → used directly. Throws on unrecognized keyword.
Resolve a :color-scale option to a gradient function t→[r g b a] (0-1 range).
nil or :sequential → dark blue to light blue (ggplot2 default).
:diverging → RdBu.
keyword → clojure2d gradient name (:inferno, :viridis/plasma, etc.).
map {:low hex :mid hex :high hex} → custom 3-stop gradient.
function → used directly.
Throws on unrecognized keyword.(resolve-palette k)Resolve a keyword to a clojure2d palette, trying aliases. Returns a non-empty palette vector, falling back to the default palette.
Resolve a keyword to a clojure2d palette, trying aliases. Returns a non-empty palette vector, falling back to the default palette.
(set-config! m)Set global config overrides. Persists across calls until reset. (set-config! {:palette :dark2 :theme {:bg "#FFFFFF"}}) (set-config! nil) — reset to defaults
Set global config overrides. Persists across calls until reset.
(set-config! {:palette :dark2 :theme {:bg "#FFFFFF"}})
(set-config! nil) — reset to defaultsShape symbols assigned to categorical shape values, in assignment order. A plot with more categories than symbols reuses them from the start of the list, which makes two categories indistinguishable -- plan time warns before that happens.
Shape symbols assigned to categorical shape values, in assignment order. A plot with more categories than symbols reuses them from the start of the list, which makes two categories indistinguishable -- plan time warns before that happens.
Default theme: background color, grid color, and font size.
Default theme: background color, grid color, and font size.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |